Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to calculate if today is before May 1

by shmem (Chancellor)
on Dec 29, 2019 at 17:05 UTC ( [id://11110730]=note: print w/replies, xml ) Need Help??


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

For "today":

shmem [qwurx] ~> perl -MDate::Parse -E 'say+(str2time("$_-05-01") >= t +ime ? "before" : "after"). " $_-05-01" for qw(2019 2020)' after 2019-05-01 before 2020-05-01 shmem [qwurx] ~>

Invoking that on 2020-05-01 will give you "after 2020-05-01". For distinguishig "before", "at" and "after" a simple ternary '? :' construct isn't enough.

For TODAY as a date in any year, just construct the input for st2time() and the TODAY epoch timestamp (use that instead of time above) according to the format of TODAY.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

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

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

    No recent polls found