Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to calculate if today is before May 1 -- oneliner

by Discipulus (Canon)
on Dec 29, 2019 at 18:16 UTC ( [id://11110734]=note: print w/replies, xml ) Need Help??


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

Hello htmanning,

Dates are delicate things, and you must use care and recommended modules, as already shown.

But for such a trivial task you can simply check if you are in January-April (months 0-3 in localtime's 4th element in the list form) ie (localtime(time))[4]<=3 to be sure being before 1st of May:

perl -E "say qq(we are ),(localtime(time))[4]<=3?qq(BEFORE):qq(AFTER), +qq( 1st of May)" we are AFTER 1st of May

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-25 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found