Perl timezone conversion - but only using core modules -
is possible timezone conversion 'arbitrary' date in future using perl core modules?
lets have day:month:year, hr:min in timezone x (assume qualified timezone america/new_york) , need convert timezone y (say asia/kolkata)
some notes:
1) osx (lion or above)
2) know how using datetime , datemanip, these not core modules, , require c compiler present installed. trying distribute program 'non technical' users - can perl module installs help, fall apart when trying xcode, command line tools etc working. have tried install datetime got caught in errors/dependencies , gave up.
3) tried using combination of tzset; , env tz - can't used arbitrary dates - works local time (which means, can convert 'now time' timezone)
use posix core module. example:
use posix; $env{tz} = 'europe/madrid'; $time_t = posix::mktime( 10, 30, 17, 4, 4, 113 ); print posix::ctime($time_t); #<-- prints: sat may 4 17:30:10 2013 $env{tz} = 'europe/london'; print posix::ctime($time_t); #<-- prints: sat may 4 16:30:10 2013
Comments
Post a Comment