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

DateTime uses Int timezone offsets. #130

Closed
wants to merge 1 commit into from

Conversation

@supernovus
Copy link
Contributor

commented Apr 24, 2013

As it says on the box, DateTime now uses Int for timezone offsets, and no longer supports Callable objects for timezone offsets. $*TZ is now an integer value representing the offset from UTC in seconds.

This also resolves the long-standing bug with regards to properly setting the offset for negative timezones.

@arnsholt

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2013

Shouldn't the timezone facility at least support rationals? There are some timezones that are half-hour offsets from UTC, for example Indian Standard Time which is UTC+4.5 if memory serves.

@arnsholt

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2013

And according to Wikipedia, Nepal is UTC+5:45, believe it or not.

@perlpilot

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2013

The offset is in seconds, so UTC+5:45 is easily handled. :-)

@xfix

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2013

Well, what if we have UTC+0:00:00.50? Oh right, YAGNI.

@supernovus

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2013

As perlpilot mentioned, the offset is in seconds, so it handles all those cases. There are courtesy methods for retrieving the offset in hours or minutes if so desired. I will be writing a DateTime::TimeZone library, inspired by the Perl 5 library of the same name, which can be used to do something like:

use DateTime::TimeZone;
my $tz = timezone('America/Vancouver');
my $dt = DateTime.now(:timezone($tz));

or alternatively:

my $tz = tz-offset('+0545');

Which will eliminate the need to know the value in seconds.

@arnsholt

This comment has been minimized.

Copy link
Contributor

commented Apr 24, 2013

Right, seconds not hours. That should be enough for most purposes. Thanks for the clarification!

Pre-standardisation of timezones, times usually refer to local solar time, I think, but that's sufficiently esoteric to be relegated to a module, I should think.

@supernovus

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2013

Just noting that the spec tests have been updated and work properly with this patch.

@moritz

This comment has been minimized.

Copy link
Member

commented Apr 26, 2013

Thanks, I've justed applied the patch.

@moritz moritz closed this Apr 26, 2013

@MasterDuke17 MasterDuke17 referenced this pull request Jun 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.