Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Daylight Savings Time twist

by BigLug (Chaplain)
on Feb 07, 2003 at 12:36 UTC ( [id://233449]=note: print w/replies, xml ) Need Help??


in reply to Re: Daylight Savings Time twist
in thread Daylight Savings Time twist

OK, we've had a talk about it and this is the best solution at the moment using the current state of the module:
use DateTime; %OurLogs = get_the_time_from_the_log_file_as_a_hash(); $here = DateTime->new( time_zone => 'America/Indiana', map { $_ => $OurLogs{$_} } qw( year month day hour minute second ) ); $there = DateTime->new( time_zone => 'America/Los_Angeles', map { $_ => $here->$_() } qw( year month day hour minute second ) );
Then you can play around with however you want to format the $here and $there objects. Check the PODumentation for details.

Replies are listed 'Best First'.
Re: Re: Re: Daylight Savings Time twist
by BigLug (Chaplain) on Feb 07, 2003 at 23:01 UTC
    Once again, I have posted the wrong solution. The above solution will give you a time difference if you subtract here from there. However to get the equivlent there time for a particular here time, do this:
    use DateTime; %OurLogs = get_the_time_from_the_log_file_as_a_hash(); $here = DateTime->new( time_zone => 'America/Indiana', map { $_ => $OurLogs{$_} } qw( year month day hour minute second ) ); $there = $here->clone; $there->set_time_zone('America/Los_Angeles');
    This will give you the equivlent time in LA for the time in Indiana. Please note that you should set the timezones to appropriate values :)

    Many appologies for all the confusion. I woke up at about 3am in a cold sweat realising that I'd posted the wrong solution :)

      Ok, all, I REALLY appreciate the comments back. Learned quite a bit in the exercise. In this case, they guy who's taking over for me is a real PL/SQL (Oracle) nut; I read this thread, and liked it best.

      I urged him to make use of it, and he tried it out, kinda liked it, but opted to use an Oracle function to handle the time shift and write a simple Perl piece that used ranges to give a proper time range. The range is based on whether or not we are between the first Sunday in April and the last Sunday in October or not. It, admittedly, was simple, but isn't the most efficient solution (of which I think BigLug's probably is).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://233449]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2024-04-18 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found