Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: ->with_time_zone_same_instant and ->with_time_zone_same_local #16

Open
Grinnz opened this issue Aug 21, 2015 · 1 comment
Open

Comments

@Grinnz
Copy link

Grinnz commented Aug 21, 2015

The section "TIME ZONES" describes how to convert a Time::Moment object to a different time zone using DateTime::TimeZone, either preserving the instant or the local time. I think it would be very convenient to have methods that take a DateTime::TimeZone object, or possibly even a string that can be passed to the DT::TZ constructor (such as you can do with DateTime->set_time_zone), and does the conversion described in those examples. I basically have a function that does this for me at the moment to avoid repeating code, but it would be more convenient to be able to do for example:

my $moment = Time::Moment->from_epoch($epoch)->with_time_zone_same_instant($tz)
@chansen
Copy link
Owner

chansen commented Aug 22, 2015

The methods can't be named ->with_time_zone_same_instant or ->with_time_zone_same_local since the time zone isn't retained with Time::Moment, perhaps ->with_time_zone_offset_same_instant and ->with_time_zone_offset_same_local, but I'll have to give this some thought. I'm not particular fond of DateTime::TimeZone's API or performance, something I intend to address (and already have done in DPAN code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants