Actually I don't think
the statement (
that parent's code will produce an incorrect time during DST) is correct but neither do I think
Robin's surmise that the code in
Re: How to convert time from one time zone to another will "work on Windows" is
universally correct.
Under Windows7:
#!/usr/bin/perl
use 5.014;
# convert TZ
say "\$ENV{TZ}: $ENV{TZ}"; # var had to be manually added on stock
+ W7
{
local $ENV{TZ} = "EST+05";
say "In New York, it is " . localtime();
}
{
local $ENV{TZ} = "IST-05:30"; # does not return c
+orrect time on W7
say "In Mumbai, it is " . localtime(); # but, rather, same
+ as NY localtime
}
outputs:
$ENV{TZ}: EST5EDT # TZ is set but this does
+
# not appear to be defaul
+t (for Win7)
In New York, it is Mon Apr 2 10:41:23 2012 # correct
In Mumbai, it is Mon Apr 2 10:41:23 2012 #obviously wrong
But this may be the result of a misconception on my part about 'doze ENV and its vars.
Anyone care to explicate?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.