Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.dec.com!jareth.enet.dec.com!edp From: edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) Newsgroups: comp.sys.handhelds Subject: Re: Julian/Gregorian Conversions Keywords: julian Message-ID: <21281@shlump.nac.dec.com> Date: 20 Mar 91 13:49:10 GMT References: <27e668c5:2479comp.sys.handhelds@hpcvbbs.UUCP> <1991Mar20.005301.3647@ux1.cso.uiuc.edu> Sender: newsdaemon@shlump.nac.dec.com Reply-To: edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) Organization: Digital Equipment Corporation Lines: 33 In article <1991Mar20.005301.3647@ux1.cso.uiuc.edu>, lnk10562@uxa.cso.uiuc.edu (Louis Koziarz) writes: >Could someone/anyone post the simple date->julian date algorithm in >pseudo-code? Credit for the formulas used for the date conversions goes to the PPC ROM User's Manual, specifically Roger Hill and Fernando Lopez-Lopez. Calendar (year, month, day) to Julian day number: y' = year + (month-2.85)/12 julian = floor( floor(floor(367*y')-floor(y')-.75*floor(y')) + d - .75*floor(y'/100) ) + 1721115 Julian day number to Calendar: j' = julian-172119.2 n' = ceiling(j'+j'/48699+.2) y' = floor((n'-.2)/365.25) n'' = n'-floor(y'*365.25) = ceiling(.2 + (n'-.2)%365.25) m' = floor((n''-.5)/30.6) day = floor(n''-30.6*m'+.5) = ceiling((m'-.5)%30.6) if (m' <= 9) month = m'+3 year = y' else month = m'-9 year = y'+1 -- edp (Eric Postpischil) "Always mount a scratch monkey." edp@jareth.enet.dec.com