Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Return local results with the offset of the local time #49
I tried to lay my hands on it, and it seems now the discussion is required. The change is by no means cosmetic, it is pretty huge and will require subsequent API change. For example:
# current API: t = Time.now # => 2016-03-24 20:10:25 +0200 tz = TZInfo::Timezone.get('Europe/Kiev') tz.utc_to_local(t) # real t timezone is ignored and just dropped, t treated as UTC # => 2016-03-24 22:10:25 UTC -- no timezone info provided, but user should think of it as "+02:00" # ...and same here, symmetrically tz.local_to_utc(t) # => 2016-03-24 18:10:25 UTC # Proposed API: tz.convert(t) # takes into consideration t's REAL utc offset # => 2016-03-24 20:10:25 +0200 -- and also provides meaningful result UTC offset
Considering number of gems depending on tzinfo (including THE Rails), not everyone will be happy with this change. But currently I can't see any other reasonable solution.
Maybe compatibility layer could be provided (or unhappy ones could just rely on concrete older version).
@zverok Thank you for your comments. Sorry for not responding earlier - I've not had the time to consider this properly.
I think that the
I'd add your
My reason for retaining the old methods is that the
I think ActiveSupport/Rails ignores the offset of the
If this ends up being an incompatible change, the major version of TZInfo will need to be incremented as per semantic versioning.
I hope to be able to work on removing the remaining Ruby 1.8 support code over the next few weeks (which may make implementing this easier). I'll then try and look into this further. In the meantime, you are welcome to submit a pull request with proposed changes and I'll take a look.