Skip to content

Instantly share code, notes, and snippets.

@overplumbum
Last active December 14, 2015 18:48
Show Gist options
  • Save overplumbum/5131630 to your computer and use it in GitHub Desktop.
Save overplumbum/5131630 to your computer and use it in GitHub Desktop.
checks if tzinfo is up-to-date for different platforms
# correct output is -03:00
pip install --upgrade --verbose pytz
python -c "from pytz import timezone as z; from datetime import datetime as d; print str(z('America/Santiago').localize(d(2013, 03, 11)))"
# correct output is 07:00
gem install tzinfo
ruby -e 'require "Date"; require "TZInfo"; t=DateTime.strptime("2013-03-11 10-00-00", "%Y-%m-%d %H-%M-%S"); t=TZInfo::Timezone.get("America/Santiago").utc_to_local(t); print(t, "\n")'
# Perl's DateTime data
# correct output is also 07:00
perl -e 'use DateTime; my $t=DateTime->new(year=>2013,month=>3,day=>11,hour=>10,time_zone=>"UTC"); $t->set_time_zone("America/Santiago"); print($t, "\n")'
# POSIX Data
perl -MPOSIX -we '$ENV{TZ} = "UTC"; my $t=mktime(0,0,10,11,3,113); $ENV{TZ} = "America/Santiago"; POSIX::tzset(); print asctime(localtime($t))'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment