Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 29, 2015 14:23
Show Gist options
  • Save tkuchiki/f9e1f94baa16fede3789 to your computer and use it in GitHub Desktop.
Save tkuchiki/f9e1f94baa16fede3789 to your computer and use it in GitHub Desktop.
6c6,7
< use Time::Local;
---
> use DateTime;
> use DateTime::Format::Strptime;
12,13c13
< $NTP_LI = timegm( 0, 0, 0, 31, 12-1, 05 ); # 05/12/31 00:00:00 UTC
< $NTP_LEAP = timegm( 0, 0, 0, 1, 1-1, 06 ); # 06/01/01 00:00:00 UTC
---
> my $current_time_zone = DateTime::TimeZone->new(name => 'local')->name();
15c15,30
< $USO_LEAP = timegm( 0, 0, 0, 11, 12-1, 05 ); # 05/12/11 00:00:00 UTC
---
> my $format = new DateTime::Format::Strptime(
> pattern => '%Y-%m-%dT%H:%M:%S',
> time_zone => 'UTC',
> );
>
> my $offset = 9;
>
> my $uso_leap_date = $format->parse_datetime($ARGV[0]);
> my $ntp_li_date = $format->parse_datetime('2015-06-30T00:00:00');
> my $ntp_leap_date = $format->parse_datetime('2015-07-01T00:00:00');
>
> $uso_leap_date->set_time_zone('UTC');
>
> $NTP_LI = $ntp_li_date->epoch;
> $NTP_LEAP = $ntp_leap_date->epoch;
> $USO_LEAP = $uso_leap_date->subtract(hours => $offset)->epoch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment