akagrawal3 has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date to epoch
by Utilitarian (Vicar) on Jul 19, 2012 at 07:38 UTC | |
The important thing to note is that the year value is $year - 1900 (but of course you are going to read the POSIX pod now anyway in order to see how strftime works to create ISO date strings ;) )
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
| [reply] [d/l] [select] |
|
Re: Date to epoch
by Marshall (Canon) on Jul 19, 2012 at 10:48 UTC | |
On perl versions older than 5.12.0, the range of dates that can be actually be handled depends on the size of time_t (usually a signed 32 bit integer) on the given platform. Currently, this is 32 bits for most systems, yielding an approximate range from Dec 1901 to Jan 2038. This integer is the number of seconds from the "epoch" or arbitrary start time/date (plus or minus).
There are a number of modules on CPAN that can handle dates greater or less than the normal Unix epoch. These are good for internal program calculations. Since the "epoch" date is arbitrary, I would not use this integer for date/time interchange between systems and I would not assume that the other system uses 64 bits vs 32 bits. | [reply] |
by akagrawal3 (Beadle) on Jul 25, 2012 at 10:29 UTC | |
| [reply] |
by Marshall (Canon) on Jul 29, 2012 at 22:57 UTC | |
Doing "date/time" math can be more complex than you might think. For a small example, this year (2012) - we had a "leap second" - WOW - what the heck does that mean?. I didn't mean to make a pun. But think about this and what might happen in 2106? | [reply] |
by locked_user sundialsvc4 (Abbot) on Jul 19, 2012 at 16:03 UTC | |
So here we go again ... welcome to the Y2038 problem. That’s only 26 years away now. Plenty of time to say the sky is falling... again. Plenty of time to write the books ... and to make the tin-foil hats. P.S.: I actually collected “Y2K books” at that time, knowing that they’d be gone in an instant ... | |
by Marshall (Canon) on Jul 21, 2012 at 23:43 UTC | |
Strictly speaking, the year should be specified in a form consistent with localtime(), i.e. the offset from 1900. In order to make the interpretation of the year easier for humans, however, who are more accustomed to seeing years as two-digit or four-digit values, the following conventions are followed
Years greater than 999 are interpreted as being the actual year, rather than the offset from 1900. Thus, 1964 would indicate the year Martin Luther King won the Nobel prize, not the year 3864.I have a 6 Mhz, pre-production PC with a Quantum "Hard Card" => This is free to "good home". This is a part of the history of the PC. Contact me if you are interested.
Computer are faster and have more storage than the Y2K models. | [reply] |
|
Re: Date to epoch
by Anonymous Monk on Jul 19, 2012 at 07:56 UTC | |
I am facing a little difficulty in using the search Here you go :) date to epoch, date epoch, site:perlmonks.org date to epoch, ?node_id=3989;HIT=date%20epoch;re=N
Found 20 nodes roughly between 2012-07-19 and 1999-10-04 (searched 100.00% of DB). where title contains all of "date", "epoch" | [reply] [d/l] |