Re: Time::Local let me faint
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 30 Aug 2006 05:30:46 -0700
John W. Krahn wrote:
Jeff Pang wrote:
$ perl -Mstrict -MTime::Local -le 'print timelocal(0,0,0,31,7,106)'
1157007600
For the instance described by you,both '2006' and '106' are right.
$ perl -Mstrict -MTime::Local -le 'print timelocal(0,0,0,31,7,106)'
1156953600
$ perl -Mstrict -MTime::Local -le 'print timelocal(0,0,0,31,7,2006)'
1156953600
The reason that '2006' works is because Time::Local makes a guess that '2006'
actually means '106'.
There is no "guesswork" involved. Time::Local has a very well
documented specific set of rules:
o Years greater than 999 are interpreted as being the
actual year, rather than the offset from 1900. Thus,
1963 would indicate the year Martin Luther King won the
Nobel prize, not the year 2863.
o Years in the range 100..999 are interpreted as offset
from 1900, so that 112 indicates 2012. This rule also
applies to years less than zero (but see note below
regarding date range).
o Years in the range 0..99 are interpreted as shorthand
for years in the rolling "current century," defined as
50 years on either side of the current year. Thus,
today, in 1999, 0 would refer to 2000, and 45 to 2045,
but 55 would refer to 1955. Twenty years from now, 55
would instead refer to 2055. This is messy, but matches
the way people currently think about two digit dates.
Whenever possible, use an absolute four digit year
instead.
Paul Lalli
.
- References:
- Re: Time::Local let me faint
- From: Jeff Pang
- Re: Time::Local let me faint
- From: John W. Krahn
- Re: Time::Local let me faint
- Prev by Date: Re: Totally lost - need a starting point
- Next by Date: Perl-mysql
- Previous by thread: Re: Time::Local let me faint
- Next by thread: Totally lost - need a starting point
- Index(es):
Relevant Pages
|