Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: DateTime::Format::Strptime Parsing Seems to have a Problem?

by ikegami (Patriarch)
on Mar 30, 2019 at 13:45 UTC ( [id://1231898]=note: print w/replies, xml ) Need Help??


in reply to DateTime::Format::Strptime Parsing Seems to have a Problem?

Tip:

our $LocalTZ = DateTime::TimeZone->new( name => 'local' ); my $dtnow = DateTime->now(time_zone => $LocalTZ);

can be written as

my $dtnow = DateTime->now( time_zone => 'local' );

Replies are listed 'Best First'.
Re^2: DateTime::Format::Strptime Parsing Seems to have a Problem?
by ozboomer (Friar) on Mar 31, 2019 at 00:35 UTC

    Right you are, ikegami... but the use of the code:

    our $LocalTZ = DateTime::TimeZone->new( name => 'local' ); my $dtnow = DateTime->now(time_zone => $LocalTZ);

    ...seems to be a practice that many folks follow, mainly in the interests of performance and consistency.

    The details are discussed in the DateTime module docs under the heading "Determining the Local Time Zone Can Be Slow".

      mainly in the interests of performance

      If you are going to use $LocalTZ more than once then storing the DateTime::TimeZone object as a variable has a performance benefit. Conversely if you are going to use it only the once then there's likely to be a (very small) performance penalty.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-25 13:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found