develooper Front page | perl.perl5.porters | Postings from July 2001

[ID 20010702.001] localtime() returns incorrect day-in-the-year value

Thread Next
From:
Kenneth Tomiak
Date:
July 2, 2001 05:19
Subject:
[ID 20010702.001] localtime() returns incorrect day-in-the-year value
Message ID:
000801c102f1$200d4900$198599a7@nycnet

This is a bug report for perl from k.tomiak@schunk-associates.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
[Environment]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
Microsoft(R) Windows 98
   (C)Copyright Microsoft Corp 1981-1998.

C:\WINDOWS>perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 626 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 01:31:15 May  2 2001


Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
[Contents of dity.pl]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
#!/usr/bin/perl

INITIALIZE_VARIABLES: {
 print "\nperl - Practical Extraction and Report Language\n";
  @daysoftheweek = ("Sunday","Monday","Tuesday","Wednesday",
                    "Thursday","Friday","Saturday");
  @daysinthemonth = (31,28,31,30,31,30,31,31,30,31,30,31);

  @monthsoftheyear = ("January","February","March","April",
                      "May","June","July","August","September",
                      "October","November","December");

  ($time_seconds, $time_minutes, $time_hours,
   $date_day_of_month, $date_month, $date_year_relative_to_1900,
   $dayofweek, $dayofyear, $daylightsavingstimezone) = localtime();

  $thisyear = $date_year_relative_to_1900 + 1900;
  $thismonth = $monthsoftheyear[$date_month];
  $thisday = $daysoftheweek[$dayofweek];
  }

  REALLY_CALCULATE_DAY_OF_YEAR: {
    $lastyear = $thisyear - 1;
    $last_century = int($lastyear / 100);
    $adjust_leap = int(($last_century * .75) + .75);
    $leapyear = $thisyear % 4;
    $notyleapyear = $thisyear % 400;
    if (($leapyear == 0) && ($notleapyear == 0)) {
        $daysinthemonth[1] = 29 ;
        }
    $realdayofyear = $date_day_of_month;
    $loop_ctr = 0;
    while ($loop_ctr < $date_month) {
      $realdayofyear = $realdayofyear + $daysinthemonth[$loop_ctr];
      $loop_ctr++;
    }
    $total_days = int(($lastyear * 1461) / 4) - $adjust_leap +
$realdayofyear;
    $day_of_week = ($total_days % 7) + 1;
    if ($realdayofyear != $dayofyear) {
      print "$thisday $thismonth $date_day_of_month, $thisyear.\n";
      print "localtime returned $dayofyear, but I know it is
$realdayofyear.\n";
      }
  }

PROGRAM_TERMINATION: {

exit 0;
}


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
[Outout from running dity.pl]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
perl - Practical Extraction and Report Language
Sunday July 1, 2001.
localtime returned 181, but I know it is 182.

---
Flags:
    category=utilities
    severity=high
---
Site configuration information for perl v5.6.1:

Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname='KET2428'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cl', ccflags
='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT 
 -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX',
    optimize='-O1 -MD -DNDEBUG',
    cppflags='-DWIN32'
    ccversion='', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='', ldflags
'-nologo -nodefaultlib -release  -libpath:"C:\usr\bin\perl\lib\CORE"  -machi
ne:x86'
    libpth="C:\usr\bin\perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ',
ddlflags='-dll -nologo -nodefaultlib -release  -libpath:"C:\usr\bin\perl\lib
\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY

---
@INC for perl v5.6.1:
    C:/usr/bin/perl/lib
    C:/usr/bin/perl/site/lib
    .

---
Environment for perl v5.6.1:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)

PATH=C:\WINDOWS;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\WINDOWS;C:\WINDOWS\COMMAND;
C:\WINDOWS\SYSTEM;C:\WINDOWS\SYSTEM\WBEM;C:\THINKPAD;D:\PROGRAMF\KENTOM~1;D:
\PROGRAMF\REXX;C:\USR\BIN\PERL\BIN\;D:\PROGRAMF\SPFPC40;D:\PROGRAMF\MTS;D:\P
rogram Files\Hummingbird\Connectivity\7.00\NFSClient\
    PERL_BADLANG (unset)
    SHELL (unset)




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About