Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to calculate if today is before May 1

by johngg (Canon)
on Dec 29, 2019 at 15:34 UTC ( [id://11110728]=note: print w/replies, xml ) Need Help??


in reply to How to calculate if today is before May 1

You could use the Time::Piece module which has been in the core Perl distribution since 5.10 I believe.

johngg@shiraz:~/perl/Monks$ perl -Mstrict -Mwarnings -MTime::Piece -E +' my $now = localtime(); my $may = Time::Piece->strptime( qq{@{ [ $now->year() ] }/05/01 00:00: +00}, q{%Y/%m/%d %T} ); say $now->epoch() < $may->epoch() ? q{Before 1st May} : q{After 1st May};' After 1st May

I hope this is helpful.

Update:The "false" part of the ternary would more accurately say "On or after 1st May" being pedantic.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found