Very nice.  Thank you!

> -----Original Message-----
> From: Anthony M. Humphreys [mailto:[EMAIL PROTECTED] 
> Sent: Friday, February 28, 2003 8:42 AM
> To: [EMAIL PROTECTED]
> Subject: Witango-Talk: Dates
> 
> 
> I was getting tired of JS and Tango only recognising a small 
> number of dates. I often need to calculate the days between 
> dates outside of the built-in date ranges. So, here's a 
> little JavaScript for us that calculates the number of days 
> between dates, using the Gregorian Calendar conventions, good 
> for ANY date.
> 
> Enjoy!
> 
> <SCRIPT>
> function daysBetweenDates() {
>       var StartYear  = new Number(1900);
>       var StartMonth = new Number(1);
>       var StartDay   = new Number(1);
>       var EndYear    = new Number(1970);
>       var EndMonth   = new Number(1);
>       var EndDay     = new Number(1);
>       function DaysFromZero (yy,mm,dd) {
>               // Corrects the month/year for the average 
> number days per month
>               if ((mm - 3)>=0) {
>                       mm = mm +  1;
>               } else {
>                       mm = mm + 13; 
>                       yy = yy -  1;
>               };
>               // Calculates the number of days from an 
> arbitrary epoch, 
>               // uses Julian formula, minus corrections for 
> Pope Gregory's leap year rules
>               return (parseInt(365.25 * yy) + parseInt(30.6 * 
> mm) + dd - parseInt(yy / 100.00) + parseInt(yy / 400));
>       };
>       var I = DaysFromZero(EndYear,EndMonth,EndDay);
>       var J = DaysFromZero(StartYear,StartMonth,StartDay);
>       return (I-J+1);
> };
> alert (daysBetweenDates());
> </SCRIPT>
>  
> 
> ______________________________________________________________
> __________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to 
> [EMAIL PROTECTED]
>                 with unsubscribe witango-talk in the message body
> 

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to