same machine, with DateTime, code first
#!/usr/bin/perl use POSIX; use Time::Local; print "Timezone: " . $ENV{TZ} . "\n\n"; &dateTimeToTimestamp("2008-03-30T00:59:59"); &dateTimeToTimestamp("2008-03-30T01:00:00"); &dateTimeToTimestamp("2008-03-30T01:00:01"); &dateTimeToTimestamp("2008-03-30T02:00:00"); &dateTimeToTimestamp("2008-10-26T00:59:59"); &dateTimeToTimestamp("2008-10-26T01:00:00"); &dateTimeToTimestamp("2008-10-26T01:00:01"); &dateTimeToTimestamp("2008-10-26T01:00:02"); &dateTimeToTimestamp("2008-10-26T01:30:00"); &dateTimeToTimestamp("2008-10-26T01:30:01"); &dateTimeToTimestamp("2008-10-26T01:30:01"); &dateTimeToTimestamp("2008-10-26T01:45:00"); &dateTimeToTimestamp("2008-10-26T01:50:00"); &dateTimeToTimestamp("2008-10-26T01:55:00"); &dateTimeToTimestamp("2008-10-26T01:55:59"); &dateTimeToTimestamp("2008-10-26T01:56:00"); &dateTimeToTimestamp("2008-10-26T01:57:00"); &dateTimeToTimestamp("2008-10-26T01:58:00"); &dateTimeToTimestamp("2008-10-26T01:59:58"); &dateTimeToTimestamp("2008-10-26T01:59:59"); &dateTimeToTimestamp("2008-10-26T02:00:00"); &dateTimeToTimestamp("2008-10-26T02:00:01"); &dateTimeToTimestamp("2008-10-26T02:59:59"); &dateTimeToTimestamp("2008-10-26T03:00:00"); &dateTimeToTimestamp("2008-10-26T03:00:01"); sub dateTimeToTimestamp { print $_[0]; print "|"; $_[0] =~ /(\d{4})-(\d{2})-(\d{2})([ |T])(\d{2}):(\d{2}):(\d{2})/; my($year, $mon, $day, $GMT, $hour, $min, $sec) = ($1, $2, $3, $4, +$5, $6, $7); use DateTime; my $dt = eval { DateTime->new( time_zone => 'UTC', year => $year, month => $mon, day => $day, hour => $hour, minute => $min, second => $sec, ); }; if($@){ print $/,$@,$/; return; } print $dt->strftime( "%Y-%m-%d %Z %H:%M:%S" ); $dt = eval { DateTime->new( time_zone => 'Europe/Dublin', year => $year, month => $mon, day => $day, hour => $hour, minute => $min, second => $sec, ); }; if($@){ print $/,$@,$/; return; } print "|"; print $dt->strftime( "%Y-%m-%d %Z %H:%M:%S" ); print "\n"; } __END__
output
Timezone: 2008-03-30T00:59:59|2008-03-30 UTC 00:59:59|2008-03-30 GMT 00:59:59 2008-03-30T01:00:00|2008-03-30 UTC 01:00:00 Invalid local time for date in time zone: Europe/Dublin 2008-03-30T01:00:01|2008-03-30 UTC 01:00:01 Invalid local time for date in time zone: Europe/Dublin 2008-03-30T02:00:00|2008-03-30 UTC 02:00:00|2008-03-30 IST 02:00:00 2008-10-26T00:59:59|2008-10-26 UTC 00:59:59|2008-10-26 IST 00:59:59 2008-10-26T01:00:00|2008-10-26 UTC 01:00:00|2008-10-26 GMT 01:00:00 2008-10-26T01:00:01|2008-10-26 UTC 01:00:01|2008-10-26 GMT 01:00:01 2008-10-26T01:00:02|2008-10-26 UTC 01:00:02|2008-10-26 GMT 01:00:02 2008-10-26T01:30:00|2008-10-26 UTC 01:30:00|2008-10-26 GMT 01:30:00 2008-10-26T01:30:01|2008-10-26 UTC 01:30:01|2008-10-26 GMT 01:30:01 2008-10-26T01:30:01|2008-10-26 UTC 01:30:01|2008-10-26 GMT 01:30:01 2008-10-26T01:45:00|2008-10-26 UTC 01:45:00|2008-10-26 GMT 01:45:00 2008-10-26T01:50:00|2008-10-26 UTC 01:50:00|2008-10-26 GMT 01:50:00 2008-10-26T01:55:00|2008-10-26 UTC 01:55:00|2008-10-26 GMT 01:55:00 2008-10-26T01:55:59|2008-10-26 UTC 01:55:59|2008-10-26 GMT 01:55:59 2008-10-26T01:56:00|2008-10-26 UTC 01:56:00|2008-10-26 GMT 01:56:00 2008-10-26T01:57:00|2008-10-26 UTC 01:57:00|2008-10-26 GMT 01:57:00 2008-10-26T01:58:00|2008-10-26 UTC 01:58:00|2008-10-26 GMT 01:58:00 2008-10-26T01:59:58|2008-10-26 UTC 01:59:58|2008-10-26 GMT 01:59:58 2008-10-26T01:59:59|2008-10-26 UTC 01:59:59|2008-10-26 GMT 01:59:59 2008-10-26T02:00:00|2008-10-26 UTC 02:00:00|2008-10-26 GMT 02:00:00 2008-10-26T02:00:01|2008-10-26 UTC 02:00:01|2008-10-26 GMT 02:00:01 2008-10-26T02:59:59|2008-10-26 UTC 02:59:59|2008-10-26 GMT 02:59:59 2008-10-26T03:00:00|2008-10-26 UTC 03:00:00|2008-10-26 GMT 03:00:00 2008-10-26T03:00:01|2008-10-26 UTC 03:00:01|2008-10-26 GMT 03:00:01

In reply to Re^2: Perl mktime/gmtime peculiarities (Inc. Testcase) [Cygwin/Windows] by Anonymous Monk
in thread Perl mktime/gmtime peculiarities (Inc. Testcase) [Cygwin/Windows] by NeilSaunders

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.