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

Re^2: Another date question

by SBECK (Chaplain)
on Aug 27, 2018 at 12:36 UTC ( [id://1221189]=note: print w/replies, xml ) Need Help??


in reply to Re: Another date question
in thread Another date question

I agree with others that in most cases, you're better off sticking with the ISO 8601 definitions. But, just in case you're interested, Date::Manip defaults to ISO 8601, but you can specify other definitions of week using some of the config variables that are built in. For example:

  • FirstDay can be used to specify a different day of the week as the first day
  • Jan1Week1 can be used to say that Jan 1 is in the first week of the year
Most of the time I would discourage using these... but they are there if you need them.

Replies are listed 'Best First'.
Re^3: Another date question [UPDATED]
by thanos1983 (Parson) on Aug 27, 2018 at 13:41 UTC

    Hello SBECK,

    Thanks a lot for this information I had no idea about that. Just to add more information in case that someone is interested those variables can be set at the config file. More information can be found in the official documentation Date::Manip::Config/BASIC CONFIGURATION VARIABLES.

    Update: Just for future reference in case that someone is interested to overwrite the ISO 8601 (not recommended). As fellow Monk SBECK indicated we can use the Jan1Week1=1 a small sample of code:

    #!/usr/bin/perl use strict; use warnings; use Date::Manip; use feature 'say'; my $datestr = ParseDate("01/01/2016"); say UnixDate($datestr,"%J"); Date_Init("Jan1Week1=1"); say UnixDate($datestr,"%J"); __END__ $ perl test.pl 2015-W53-5 2016-W01-5

    In case that someone does not want to define the config file is can load the configurations like this. More information on the official documentation. Sample of config file can be found here Date::Manip::ConfigFile - sample config file.

    BR / Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2024-03-29 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found