google-api-ads-ruby icon indicating copy to clipboard operation
google-api-ads-ruby copied to clipboard

AdManagerApi::AdManagerDateTime#to_time returns incorrect UTC offset

Open adherr opened this issue 7 months ago • 0 comments

Hello!

I'm using the LineItemService, and I'd like to convert the startDateTime into a Ruby Time object to do some comparison. I discovered that the to_time method returns the incorrect UTC offset during daylight saving time periods.

This is because we're using the utc_offset method in TZInfo, which always returns the base offset without considering daylight saving. We could use utc_total_offset, but the way it is used, we always call it with the current time rather than the time that is being converted.

I think the correct solution is to pass the timezone object to the Time constructor rather than a utc_offset.

adherr avatar Jul 02 '25 22:07 adherr