Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.c Subject: Re: Julian date routines needed Message-ID: <15367@lanl.gov> Date: 21 Feb 91 16:23:59 GMT References: <408@ceco.ceco.com> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 21 From article <408@ceco.ceco.com>, by garry@ceco.ceco.com (Garry Garrett): > [...] > There is an easy way to do this. Let UNIX do all the work FOR you. > [...] > Generally speaking, on a unix system, if you can convert the time that you > are given, in whatever format you are given to either structure tm (defined > in time.h) or into the number of seconds elapsed since jan 1, 1970 at 00:00:00, > then you can do anything you want to with it. [...] You should be advised however that UNIX leaves dates before 1 Jan. 1970 completely undefined. Further, on a 32 bit machine, the value becomes undefined for dates after (about) 3 Jan. 2038 (the seconds since epoch becomes negative then). So, if your need for the Julian Day Number is for something other than current events, the use of built-in UNIX system features won't work. The first chapter of the 'Numerical Recipes' book contains algorithms that work for all dates since 4017 (I think) B.C.. It can easily be extended to be accurate for all dates (I have a version which only overflows at year 40,000 (AD or BC)). J. Giles