Unix and my pc give different answers when running this code. pc returns 39843 and unix returns 41338 and unix gives the correct answer.

#!/bin/perl58 use Time::Local; $date='3/5/2013'; $dbt=&daysbetween('1/1/1904',$date); $dbt += 1462;# for 1900-1903 plus 2 days warn "$dbt $date and 1/1/1900\n"; #--------------------------------------------------------------------- +-------- sub daysbetween { my($dte,$dte1)= @_; my ( $mo, $dy, $yr) = split /\//, $dte; my ( $mo1, $dy1, $yr1) = split /\//, $dte1; $mo = $mo - 1; $mo1 = $mo1 - 1; if($dy > 31 || $dy < 1){ warn "$transid $dte $dte1\n"; return 1000000; } if($dy1 > 31 || $dy1 < 1){ warn "$transid $dte $dte1\n"; return 1000000; } if($mo > 11 || $mo < 0){ warn "$transid $dte $dte1\n"; return 1000000; } if($mo1 > 11 || $mo1 < 0){ warn "$transid $dte $dte1\n"; return 1000000; } if($yr > 2037){ warn "$transid $dte $dte1\n"; return 1000000; } if($yr1 > 2037){ warn "$transid $dte $dte1\n"; return 1000000; } my $ltime = timelocal ( 0, 0, 1, $dy, $mo, $yr ); my $ltime1 = timelocal ( 0, 0, 1, $dy1, $mo1, $yr1 ); my $days=sprintf("%.0f",($ltime1-$ltime)/86400); return $days; } #--------------------------------------------------------------------- +--------

In reply to days between dates by StayTheCourse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.