googleads / googleads/google-api-ads-ruby

AdManagerApi::AdManagerDateTime#to_time returns incorrect UTC offset

Open
#205 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.