googleads / googleads/google-api-ads-ruby
AdManagerApi::AdManagerDateTime#to_time returns incorrect UTC offset
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 303
- Forks
- 221
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at AdManagerApi::AdManagerDateTime#to_time and inspect how the timezone is applied when converting startDateTime. Exercise the conversion across a daylight-saving period and verify that the resulting Ruby Time has the correct UTC offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100