piclist 2001\01\10\050043a >
Thread: Time diff code
www.piclist.com/techref/microchip/time.htm?key=time
flavicon
face BY : Kübek Tonyemail (remove spam text)



Hi again, here's a implementation of calculation of julian date:
( shouldn't be to hard to implement in a pic :) )

long BIORHYTHM::JulianDate(UIW_DATE *dateField)
{
       int year;
       int month;
       int day;

       // Get the year, month, and day.
       UI_DATE date = *dateField->DataGet();
       date.Export(&year, &month, &day);

       // A Julian Date is defined as 'a day count starting at 1200 UT
on
       // 1 January -4713' by the U.S. Naval Observatory.  A date
entered is
       // assumed to be after 1200 UTC.  This algorhythm is valid for
any date
       // after Jan. 1, 1700 and accounts for all leap years (including
       // centessimal years and centessimal years divisible by 400).
This
       // algorithm (by Wayne Rust) is useful because it automatically
       // takes the number of days in each month into account and does
not use
       // floating point arithmetic.
       //
       // The day of week can also be computed from this by finding
       // JulianDate % 7 + 1. (1 = Sun, 2 = Mon, etc.)
       year -= 1700 + (month < 3);
       return (365L * (year + (month < 3)) + year / 4 - year / 100 +
               (year + 100) / 400 + (305 * (month - 1) - (month > 2) *
20 +
               (month > 7) * 5 + 5) / 10 + day + 2341972L);
}


Then you 'just' need to add the hour and minutes to achive you goal.

/Tony


Tony Kübek, Flintab AB            
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
E-mail: spam_OUTtony.kubekRemoveMEspamflintab.com
²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservspam_OUTspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


<200101100958.KAA02130@mn10.swip.net> quoted-printable

See also: www.piclist.com/techref/microchip/time.htm?key=time
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Time diff code

month overview.

new search...