Join GitHub today
Getting timezone identifiers from time objects #90
Thanks for developing and maintaining this useful gem!
I've been testing out 2.0.0.pre1 and looking into using it to eliminate some other timezone abstractions and dependencies in various projects. The blocker I keep hitting is that there's no way to get the timezone from a time, either the object or its identifier which is what I really want. For example:
require "tzinfo" zone = TZInfo::Timezone.get("America/New_York") time = zone.local_time(2015, 2, 24, 10, 0, 0) time.zone # => "EST" # How to get "America/New_York" from time, without a reference to zone?
Similar situation to what was discussed briefly in #86 which I'm assuming is because Time#zone is already well defined and needing to be compatible with that. A few options I can think of:
Would any of these be acceptable, or any other solutions that would be preferable?
The current implementation on master returns extended
I have considered including a reference to the
Firstly, there are places that construct extended local times that don't have any reference to the
The second reason is that, for me, just adding the associated
My current plan is to release 2.0.0 with
TZInfo::TimeWithZone.new('America/New_York', 2015, 2, 24, 10, 0, 0) TZInfo::TimeWithZone.new('America/New_York, Time.now.utc)
That makes sense, thanks for the detailed explanation.
Agree it could get messy with all those other classes involved. Appreciate wanting to implement it more thoroughly, my use case is simpler because I don't need the arithmetic.
Looking forward to the 2.0.0 release.