Last change
on this file since 6888aa2 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
1.1 KB
|
Rev | Line | |
---|
[3ae31e9] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | jday.c -- convert date to Julian day. -- ACM algorithm 199
|
---|
| 4 |
|
---|
| 5 | A Julian day is the number of days since some base date
|
---|
| 6 | in the very distant past.
|
---|
| 7 |
|
---|
| 8 | Handy for getting date of x number of days after a given Julian date
|
---|
| 9 | Use jdate() to get that from the Gregorian date.
|
---|
| 10 |
|
---|
| 11 | Written by: Robert G. Tantzen
|
---|
| 12 |
|
---|
| 13 | Translated to C by: Nat Howard
|
---|
| 14 |
|
---|
| 15 | Revised by: D.N. Lynx Crowe
|
---|
| 16 | 1998-01-14 -- optimized for speed
|
---|
| 17 |
|
---|
| 18 | Translated from the algol original in Collected Algorithms of the <ACM
|
---|
| 19 | This and jdate() are algorithm 199.
|
---|
| 20 | =============================================================================
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | long
|
---|
| 24 | jday(mon, day, year)
|
---|
| 25 | int mon, day, year;
|
---|
| 26 | {
|
---|
| 27 | register long y = year;
|
---|
| 28 | register long m = mon;
|
---|
| 29 | register long j;
|
---|
| 30 | register long ya;
|
---|
| 31 | register long c;
|
---|
| 32 | long d = day;
|
---|
| 33 |
|
---|
| 34 | if(m > 2) {
|
---|
| 35 |
|
---|
| 36 | m -= 3L;
|
---|
| 37 |
|
---|
| 38 | } else {
|
---|
| 39 |
|
---|
| 40 | m += 9L;
|
---|
| 41 | --y;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | c = y / 100L;
|
---|
| 45 | ya = y - (100L * c);
|
---|
| 46 |
|
---|
| 47 | j = (146097L * c) / 4L
|
---|
| 48 | + (1461L * ya) / 4L
|
---|
| 49 | + (153L * m + 2L) / 5L
|
---|
| 50 | + d + 1721119L;
|
---|
| 51 |
|
---|
| 52 | return(j);
|
---|
| 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.