f



FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant? #6 427498

This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

    Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl is
    Y2K compliant (whatever that means). The programmers you've hired to use
    it, however, probably are not.

    Long answer: The question belies a true understanding of the issue. Perl
    is just as Y2K compliant as your pencil--no more, and no less. Can you
    use your pencil to write a non-Y2K-compliant memo? Of course you can. Is
    that the pencil's fault? Of course it isn't.

    The date and time functions supplied with Perl (gmtime and localtime)
    supply adequate information to determine the year well beyond 2000 (2038
    is when trouble strikes for 32-bit machines). The year returned by these
    functions when used in a list context is the year minus 1900. For years
    between 1910 and 1999 this *happens* to be a 2-digit decimal number. To
    avoid the year 2000 problem simply do not treat the year as a 2-digit
    number. It isn't.

    When gmtime() and localtime() are used in scalar context they return a
    timestamp string that contains a fully-expanded year. For example,
    "$timestamp = gmtime(1005613200)" sets $timestamp to "Tue Nov 13
    01:00:00 2001". There's no year 2000 problem here.

    That doesn't mean that Perl can't be used to create non-Y2K compliant
    programs. It can. But so can your pencil. It's the fault of the user,
    not the language. At the risk of inflaming the NRA: "Perl doesn't break
    Y2K, people do." See http://www.perl.org/about/y2k.html for a longer
    exposition.



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.
0
PerlFAQ
11/27/2009 11:00:31 PM
comp.lang.perl.misc 33233 articles. 2 followers. brian (1246) is leader. Post Follow

13 Replies
652 Views

Similar Articles

[PageSpeed] 8

In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
> This is an excerpt from the latest version perlfaq4.pod, which
> comes with the standard Perl distribution. These postings aim to 
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
> 
> --------------------------------------------------------------------
> 
> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

I don't believe that this is still a FAQ. What sort of person would be
asking it ten years after the event?

   Justin.

-- 
Justin C, by the sea.
0
Justin
11/28/2009 1:46:54 PM
On 2009-11-28 13:46, Justin C <justin.0911@purestblue.com> wrote:
> In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
>
> I don't believe that this is still a FAQ. What sort of person would be
> asking it ten years after the event?

I predict that it won't take very long until programs start breaking
when they have to deal with dates before 2000.

Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).

	hp

0
Peter
11/28/2009 3:30:16 PM
On Sat, 28 Nov 2009 16:30:16 +0100, Peter J. Holzer <hjp-usenet2@hjp.at>  
wrote:

> Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).

Not out of the box, but there is a Y2038 module which makes it compliant.
0
Jochen
11/28/2009 4:49:39 PM
Justin C wrote:

> In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
>> This is an excerpt from the latest version perlfaq4.pod, which
>> comes with the standard Perl distribution. These postings aim to
>> reduce the number of repeated questions as well as allow the
>> community to review and update the answers. The latest version of the
>> complete perlfaq is at http://faq.perl.org .
>> 
>> --------------------------------------------------------------------
>> 
>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
> 
> I don't believe that this is still a FAQ. What sort of person would be
> asking it ten years after the event?
> 
>    Justin.
> 

Probably the same people that still create or see the problem.  I've
seen a lot of sites online still show odd dates for the year.  But,
you're right in a way, because those people will never read (or care to
read) the FAQ anyway.
-- 
Not really a wanna-be, but I don't know everything.
0
Wanna
11/28/2009 9:41:05 PM
In article <slrnhh2gg8.323.hjp-usenet2@hrunkner.hjp.at>, Peter J. Holzer wrote:
> On 2009-11-28 13:46, Justin C <justin.0911@purestblue.com> wrote:
>> In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
>>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
>>
>> I don't believe that this is still a FAQ. What sort of person would be
>> asking it ten years after the event?
> 
> I predict that it won't take very long until programs start breaking
> when they have to deal with dates before 2000.
> 
> Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).

See FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

   Justin.

-- 
Justin C, by the sea.
0
Justin
11/28/2009 10:28:49 PM
Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2009-11-28 13:46, Justin C <justin.0911@purestblue.com> wrote:
> > In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
> >> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
> >
> > I don't believe that this is still a FAQ. What sort of person would be
> > asking it ten years after the event?
> 
> I predict that it won't take very long until programs start breaking
> when they have to deal with dates before 2000.
> 
> Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).

5.12 will be, insofar as the underlying OS allows (with very reasonable
workarounds where it doesn't).

Ben

0
Ben
11/28/2009 10:31:11 PM
In article <slrnhh2gg8.323.hjp-usenet2@hrunkner.hjp.at>,
Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>On 2009-11-28 13:46, Justin C <justin.0911@purestblue.com> wrote:
>> In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
>>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
>>
>> I don't believe that this is still a FAQ. What sort of person would be
>> asking it ten years after the event?
>
>I predict that it won't take very long until programs start breaking
>when they have to deal with dates before 2000.
>
>Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).

Nope.

dmcanzi@tribulation $ cat ~/bin/ctime
#!/usr/bin/perl
printf "%s\n", scalar localtime eval shift;
dmcanzi@tribulation $
dmcanzi@tribulation $ ctime 0x7fffffff
Mon Jan 18 22:14:07 2038
dmcanzi@tribulation $ ctime 0x80000000
Fri Dec 13 15:45:52 1901
dmcanzi@tribulation $

Around Y2K, many programs that had used a "%02d" format for the
year were changed to use "%04d" or "%4d".  This will cause trouble
in the future -- only "%d" is Y10K compliant.

-- 
David Canzi
0
dmcanzi
11/28/2009 11:12:36 PM
Quoth Justin C <justin.0911@purestblue.com>:
> In article <slrnhh2gg8.323.hjp-usenet2@hrunkner.hjp.at>, Peter J. Holzer wrote:
> > On 2009-11-28 13:46, Justin C <justin.0911@purestblue.com> wrote:
> >> In article <jSYPm.59723$rE5.9343@newsfe08.iad>, PerlFAQ Server wrote:
> >>> 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> >> I don't believe that this is still a FAQ. What sort of person would be
> >> asking it ten years after the event?
> > 
> > I predict that it won't take very long until programs start breaking
> > when they have to deal with dates before 2000.
> > 
> > Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).
> 
> See FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?

I believe Peter's point was that the FAQ answer doesn't address that
question.

Ben

0
Ben
11/28/2009 11:34:41 PM
In article <hlo8u6-uok1.ln1@osiris.mauzo.dyndns.org>, Ben Morrow wrote:
> 
> Quoth Justin C <justin.0911@purestblue.com>:
>> See FAQ 4.18 Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
> 
> I believe Peter's point was that the FAQ answer doesn't address that
> question.

Hardly surprising when it isn't the subject of the FAQ! I'm not saying
that that FAQ should be scrapped, but maybe it needs re-naming and
updating.

   Justin.

-- 
Justin C, by the sea.
0
Justin
11/29/2009 1:08:16 AM
On Sun, 29 Nov 2009 00:12:36 +0100, David Canzi  
<dmcanzi@remulak.uwaterloo.ca> wrote:

> Around Y2K, many programs that had used a "%02d" format for the
> year were changed to use "%04d" or "%4d".  This will cause trouble
> in the future -- only "%d" is Y10K compliant.

What causes trouble is that in 2038, the 32 bit date representation that  
is used by most software, including the C libraries used by perl, ends.  
Dates larger than that can simply not be expressed.

There is a Perl module Time::y2038 which fixes that.
0
Jochen
11/29/2009 8:38:33 AM
In article <hesap4$a9q$1@rumours.uwaterloo.ca>, David Canzi
<dmcanzi@remulak.uwaterloo.ca> wrote:


> >Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).
> 
> Nope.
> 
> dmcanzi@tribulation $ cat ~/bin/ctime
> #!/usr/bin/perl

Well, you're using an older perl then.
0
brian
12/1/2009 5:14:24 PM
In article <e7m7u6-n7r.ln1@purestblue.com>, Justin C
<justin.0911@purestblue.com> wrote:

> > 4.18: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
> 
> I don't believe that this is still a FAQ. What sort of person would be
> asking it ten years after the event?

I'll update the questiona and answer.

Thanks,
0
brian
12/1/2009 5:14:50 PM
In article <011220091114245899%brian.d.foy@gmail.com>,
brian d foy  <brian.d.foy@gmail.com> wrote:
>In article <hesap4$a9q$1@rumours.uwaterloo.ca>, David Canzi
><dmcanzi@remulak.uwaterloo.ca> wrote:
>> >Also, the year 2038 is approaching. Is perl Y2038-compliant yet? ;-).
>> 
>> Nope.
>> 
>> dmcanzi@tribulation $ cat ~/bin/ctime
>> #!/usr/bin/perl
>
>Well, you're using an older perl then.

Undoubtedly.  And undoubtedly it will always be so.

-- 
David Canzi
0
dmcanzi
12/1/2009 7:09:59 PM
Reply: