T.R | Title | User | Personal Name | Date | Lines |
---|
460.1 | is this too simple to work? | CSC32::M_AMBER | | Mon May 04 1987 20:24 | 6 |
| Is there something wrong with:
If mod(year/4)=0 then leap_year=true
It seems to work fine for me for all (?) dates in our current
calandar system.
|
460.2 | Yes, it's too simple to work | CAFEIN::PFAU | Now where did I leave my marbles? | Mon May 04 1987 21:12 | 15 |
| It's not that simple.
If mod(year,4)=0 then leap_year = true
*UNLESS*
mod(year,100)=0 in which case, leap_year = false
*UNLESS*
mod(year,400)=0 in which case, leap_year = true again.
To sum it all up, if the year is divisible by 4, it's a leap year
unless it's a century year in which case it's only a leap year if
the century is divisible by 4.
Clear as mud?
tom_p
|
460.3 | | ALBANY::KOZAKIEWICZ | You can call me Al... | Mon May 04 1987 22:18 | 16 |
| >I'm trying to compute the elapsed time
>between two dates in years, days, hours, minutes, etc.
Are these VMS absolute dates? I found out empirically the difference
between the storage formats of absolute and delta times. The absolute
time is just like it says in the book, i.e. an unsigned quadword containing
the number of 100 nanaosecond intervals since November 17, 1858 (or
whatever is is...). Delta times are the ones complemnent of an absolute
time. For example, "1 12:00:00.00" is the ones complement of
"18-NOV-1858 12:00:00.00". I have written a couple of routines in
MACRO, callable from FORTRAN, which do things like subtract absolute
dates to yield a delta time, subtract a delta time from an absolute
time to yield an absolute time, and functions for the comparisons
of VMS dates (LT, LE, GT, GE). I will post them here if there is an
interest.
|
460.4 | A nit: 2's complement, not 1's | DELNI::CANTOR | Dave C. | Mon May 04 1987 23:54 | 11 |
| Re .3
Delta times are ones [sic] complements for absolute times,
but not in the way you mean. In the way you mean, they are
two's complements, in other words, the algebraic negatives
(additive inverses). "1 12:00:00.00" is the negative (not
the complement) of "18-NOV-1858 12:00:00.00". Were that not
so, then a quadword of all one-bits would be a zero delta time
rather then a delta of .000000100 seconds.
Dave C.
|
460.5 | | PASTIS::MONAHAN | | Tue May 05 1987 01:20 | 9 |
| What range of dates are you considering? The previous replies
give the rules for from about a couple of hundred years ago to the
resonably forseeable future.
Before that, they used different rules for leap years, and as
a result had a cumulative error. The rules were changed and the
adjustment for the cumulative error was made in different countries
at different times. So if you want to handle older dates, your
algorithm becomes more complex again, and becomes country dependant.
|
460.6 | Did I hear someone say "country-specific?" | MAY20::MINOW | I need a vacation | Tue May 05 1987 13:17 | 7 |
| For more information than you want (or need), feel free to copy
BOLT::DECUSC$LIBRARY:[TOOLS]CALEND.C.
It might also be in the toolshed.
Martin.
|
460.7 | Thanks | CSC32::M_BAKER | | Wed May 06 1987 14:12 | 4 |
| Many thanks to those who responded here and via mail. I think I
have what I need now. This date stuff can get real tricky sometimes.
Mike
|
460.8 | Stan said it best | DELNI::GOLDSTEIN | This Spot Intentionally Mel Blanc | Thu May 07 1987 16:50 | 1 |
| see 216.13!
|