in reply to Lady /DATE

Uh ... looks like you've done lots of work but, well, what's w/ all the 'lady' stuff. Just tried a bit, but:
use lib '.'; use lady_date; my $date = new Lady_DATE; print $date->get_days_since_new_year(3,1);
wouldn't work (or pass -w) until:
sub get_days_since_new_year{ my $self = shift; my ($__month, $__day) = @_; my (@monthdays); @monthdays = ("31","28","31","30","31","30","31","31","30","31","30"," +31"); my $days = 0; # you want to skip this month and only go back Feb. Jan # 01/01 should return 1, not 31+1 while (--$__month > 0){ $days = $days + $monthdays[$__month]; }

a

Replies are listed 'Best First'.
Re: Re: Lady /DATE
by Steeeeeve (Initiate) on Feb 02, 2001 at 13:24 UTC

    No,, The date today should be 20010331801.

    2001 033 rd day of the year and 1801 for 601 pm (If its that time of course.)

    Julian system counts the days of the solar year. 1 to 365. Its theoretically prudent to precompute the Julian date for making fast comparisons later. Just my theory. Also can quickly add and subtract quantities of time using this format.

    Lady was my diabetic Golden Retriever. I dedicated lots of my early Perl to her.

    -Steeeeeve
      okay:
      while ($__month >= 0){ $days = $days + $monthdays[$__month]; --$__month; }
      for "2/1" $__month is 2, you'll add 28 + 31 + 1 and get '60'.
      So my fix didn't work so well. Either knock one off the month to start w/ or put "0" at the beginning of the month array so that $__month == 0 adds zero, not 31. i.e.
      @monthdays = ("0", "31","28","31","30","31","30","31","31","30","31"," +30","31"); my $days = 0; while (--$__month >= $[){ $days = $days + $monthdays[$__month]; #--$__month; } $days = $days + $__day;
      while (--$__month >= 0 )

      a

        /me wonders if either of you are aware that all of these versions of get_days_since_new_year will be broken in about a month anyway.