I actually do want the date half way around the world :) The 'local' was taken out because the script is still a work-in-progress, so to speak.

I've got the following now:

... my $tz_ny = "America/New_York"; my $tz_ln = "Europe/London"; my $tz_tk = "Asia/Tokyo"; my $tz_hk = "Asia/Hong_Kong"; my $tz_se = "Asia/Seoul"; my $tz_mo = "Europe/Moscow"; ... if ($region =~ /ny/) { $today_tmp = DateTime->now( time_zone => $tz_ny); print "it is $today_tmp now in NY\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } elsif ($region =~ /ln/) { $today_tmp = DateTime->now( time_zone => $tz_ln); print "it is $today_tmp now in LN\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } elsif ($region =~ /tk/) { $today_tmp = DateTime->now( time_zone => $tz_tk); print "it is $today_tmp now in TK\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } elsif ($region =~ /hk/) { $today_tmp = DateTime->now( time_zone => $tz_hk); print "it is $today_tmp now in HK\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } elsif ($region =~ /se/) { $today_tmp = DateTime->now( time_zone => $tz_se); print "it is $today_tmp now in SE\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } elsif ($region =~ /mo/) { $today_tmp = DateTime->now( time_zone => $tz_mo); print "it is $today_tmp now in MO\n"; $tomorrow_tmp = DateTime->now()->add( days => 1 ); $yesterday_tmp = DateTime->now()->subtract( days => 1 ); } $today = $today_tmp->mdy('/'); $tomorrow = $tomorrow_tmp->mdy('/'); $yesterday = $yesterday_tmp->mdy('/'); print "Today ($region): $today -=- "; print "Tomorrow ($region): $tomorrow -=- "; print "Yesterday ($region): $yesterday -=- "; $next_business_day = `$holiday_script "$today" $region`; chomp($next_business_day); print "Next business day: $next_business_day\n"; $today_local_tmp = DateTime->now( time_zone => 'local'); $tomorrow_local_tmp = DateTime->now()->add( days => 1 ); $yesterday_local_tmp = DateTime->now()->subtract( days => 1 ); $today_local = $today_local_tmp->mdy('/'); $tomorrow_local = $tomorrow_local_tmp->mdy('/'); $yesterday_local = $yesterday_local_tmp->mdy('/'); print "Today (local (NY) ): $today_local -=- "; print "Tomorrow (local (NY) ): $tomorrow_local -=- "; print "Yesterday (local (NY) ): $yesterday_local -=- "; $next_business_day_local = `$holiday_script "$today" ny`; chomp($next_business_day_local); print "Next business day (local (NY) ): $next_business_day_local\n"; ...

So in essence I have 2 variables - one for whatever timezone I'm interested in at the moment, and another one that always contains local time.

As for now and today - was just playing around and replaced it, then never switched it back :)


In reply to Re^6: Parsing/regex question by vxp
in thread Parsing/regex question by vxp

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.