On Thu, 5 Jan 2012 09:15:31 -0500, John Gilmore <[email protected]>
wrote:

>Assuming that hh.mm.ss values are 24-hour clock ones---0 <= hh <= 23,
>0 <= mm <= 59, and 0 <= ss <= 59---the fractional part of a day
>represented by such a value is given by first calculating the number
>of seconds it represents as
>
>S = (hh  x  3600 + mm x 60 + ss) = 60 x (hh x 60) + ss
>
>Then, since there are 24 x 60 x 60  = 86400 seconds in a day, the
>fractional part of a day F represented by an hh.mm.ss value is just
>
>F = S/86400.
>
>The Gregorian Day, negative, zero, or  positive number of elapsed days
>since the epoch origin of the Gregorian calendar (0000 December 31,
>midnight) in obvious y, m, d notation is given by
>
>  p = y - 1                  --serial number, preceding year
>  G = 365p                --include 365 days, every preceding year
>         + p/4                --include preceding Julian leap years
>      - p/100                --exclude all Gregorian centurial years
>      + p/400               --include Gregorian centurial leap years
>      + CDIMT(m)       --include preceding months' days (table)
>      + d                      --include current month's days
>
>in which DDIMT(1:12) has the elements
>
>  0,31,59,90,120,151,181,212,243,273,304,334  [,365]
>
>in  a non-leap year and the elements
>
>  0,31,60,91,121,152,182,213,244,274,305,335  [,366]
>
>in a leap year.
>
>The determination of a leap year mirrors that of the pseudo-PL/I
>statement
>
>   leap = (mod(y,4) = 0) & (mod(y,100) �= 0))
>      | (mod(y,400) = 0) & (y �= 3600)  ;
>
>in which the BIF mod is defined as it is in mathematics and PL/I,
>NOT as the remainder operation is defined in C.
>
>If your GD value is a signed fullword one, dates about 58 million
>years before and after the Gregorian-calendar epoch origin can be
>represented.  This is enough for most business purposes, but this
>scheme can be used mutatis mutandis with signed doubleword integers if
>not
>
>There are LE library routines that do things like this, and if you
>find anything about the lines I have written puzzling, you should use
>one.
>
>John Gilmore, Ashland, MA 01721 - USA

Thanks, but I think the CONVTOD will do what I want.  I already have the
code I originally wrote now working, (I had messed up and where I subtracted
60, I should have subtracted 24, it fixed the problem), but I think the
CONVTOD might work out to less code since I don't have to do a lot of what I
do now.  I won't know until I give it a shot this weekend.

Brian

Reply via email to