[comp.misc] Julian Date/Day Number

philm@astroatc.UUCP (Phil Mason) (11/09/87)

There has been a bit of discussion about the Julian Date/Day Number system.

A Julian Date (or Day Number) is the number of days since an event in Roman 
history.  Julius Ceasar, in addition to being a great military leader, was 
also a great calendar maker.  The Julian Date was a marker of a new era, 
not the day-to-day marking of time that the Romans used in their daily lives.
Julius also revamped the existing "mundane" Roman calendar to better reflect 
reality.  In fact, Julius' calendar is almost exactly what we use today, Pope
Gergory only tuned Julius' ( and his calendar making successor's ) work to 
take into account the small errors that were not originally accounted for.

Julian dates are used by astronomers to give a simple way of calculating the
intervals between dates.

If you think about it, Julian Dates make alot of sense in fixing dates and
intervals accurately especially when Western calendars have changed so many 
times over the last few millenia.  Julian dates have no 'Seasons', you don't
plant your crops or fix the holidays by them.  They have no purpose except
for interval taking.


-- 
Kirk  : Bones ?                |  Phil Mason, Astronautics Technology Center
Bones : He's dead Jim.         |  Madison, Wisconsin - "Eat Cheese or Die!"
...seismo-uwvax-astroatc!philm |  I would really like to believe that my
...ihnp4-nicmad/               |  employer shares all my opinions, but . . . 

philm@astroatc.UUCP (Phil Mason) (11/10/87)

By the way . . .

November 9, 1987 is Julian Day  2447109.

This would place the event that the Julian system celebrates in the 5th 
millenium B.C. (Approximately 4700 at 365 days/year).  I can't recall what the 
supposed event was, but obviously it was calculated and not 'historically' 
recorded.

Anyone out there know what it was?


-- 
Kirk  : Bones ?                |  Phil Mason, Astronautics Technology Center
Bones : He's dead Jim.         |  Madison, Wisconsin - "Eat Cheese or Die!"
...seismo-uwvax-astroatc!philm |  I would really like to believe that my
...ihnp4-nicmad/               |  employer shares all my opinions, but . . . 

rjh@ihlpa.ATT.COM (45261-Herber) (11/10/87)

Astronomical Julian Dates/Day Number number from January 1, 4713 BC.
That date was picked because a number of various different calendar
cycles come to their initial points then and for most purposes is
sufficiently far into the past that all {:-)} useful dates are
positive numbers.
I am including a program that computes the astronomical Julian Date
using the Roman Catholic church's definition of when the switch
between the Julian and the Georgian calendars occurred, i.e. Oct 4,
1582 Old Style was followed by Oct 15, 1582 New Style.

	Randolph J. Herber, Amdahl Sr Sys Eng, ..!ihnp4!ihlpa!rjh,
	(312) 979-6553, IH 6X213, AT&T Bell Labs, Naperville, IL 60566

#include <stdio.h>
#include <time.h>
/*
This program writes a astronomical Julian date (to stdout). 
If no argument is specified, it calls a "ctime"
function to use today's date.  Otherwise, it may be invoked
with 3 arguments -- month, day, year (4-digit).
*/

#define TRUE     1
#define FALSE    0

static int mlen[] = {
	0,31,28,31,30,31,30,31,31,30,31,30,31
};

int unit(f1,f2)
	int f1, f2;
{
	int rmdr;
	rmdr = f1 % f2;
	if (rmdr < 0) rmdr += f2;
	return (f1 - rmdr) / f2;
}

main(argc,argv)
int argc;
char **argv;
{

	long secs, time();
	struct tm *tbuf, *localtime();
	void exit();
	int year, yr, mo, da, unit();
	long jdate;
	short yrm1, n;
	char style,leap;

	if (argc > 1 && argc != 4) {
		(void) printf("Usage:  No arguments for today's date,");
		(void) printf(" or '%s <mo> <da> <yr>'.\n", argv[0]);
		(void) exit(1);
	}
	else if (argc == 1) {
		secs = time((long *)0);
		tbuf = localtime(&secs);
		mo = tbuf->tm_mon + 1;
		da = tbuf->tm_mday;
		year = tbuf->tm_year + 1900;
	}
	else {
		mo = atoi(argv[1]);
		da = atoi(argv[2]);
		year = atoi(argv[3]);
	}

	if (year != 0 && year > -10000 && year < 10000) {
		yr = year > 0 ? year : year + 1;
		style = year > 1582;
		leap = style
		    ? (((yr % 4) == 0) && ((yr % 100) != 0)) ||
			((yr % 400) == 0)
		    : ((yr % 4) == 0);
		mlen[2] = leap ? 29 : 28;
		if (mo >=1 && mo <= 12 && da >= 1 && da <= mlen[mo] &&
		    !(year == 1582 && (mo == 1 || mo == 2 ||
		    (mo == 10 && da >= 5 && da <= 14)))) {
			if (year == 1582 && mo == 10) {
				mlen[10] = 21;
				if (da >= 15) da -= 10;
			} else {
				mlen[10] = 31;
			}
			yrm1 = yr - 1;
			jdate = 1721423l+yrm1*365+unit(yrm1,4)+da;
			for (n=1;n<mo;++n) {
				jdate += mlen[n];
			}
			if (style) {
				jdate -= 10 + (yrm1-1500)/100 - (yrm1-1200)/400;
			}
			(void) printf("%ld\n",jdate);
			(void) exit(0);
		} else {
			(void) printf("%s: Invalid date!\n",*argv);
			(void) exit(1);
		}
	}
	(void) printf("%s: Date out of range!\n",*argv);
	(void) exit(2);
}

int unit(f1,f2)
	int f1, f2;
{
	int rmdr;
	rmdr = f1 % f2;
	if (rmdr < 0) rmdr += f2;
	return (f1 - rmdr) / f2;
}

rwl@uvacs.CS.VIRGINIA.EDU (Ray Lubinsky) (11/12/87)

In article <557@astroatc.UUCP>, philm@astroatc.UUCP (Phil Mason) writes:
:
> A Julian Date (or Day Number) is the number of days since an event in Roman 
> history.  Julius Ceasar, in addition to being a great military leader, was 
> also a great calendar maker.  The Julian Date was a marker of a new era, 

As I mention in <2078@uvacs.CS.VIRGINIA.EDU>, the Julian period is based on an
essentially arbitrary date and has no relation whatsoever to the calendar of
Julius Caesar (other than the fact that the solar year was taken to be 365.25
mean solar days).

Where do people come up with these ``facts''?  (I got mine from the
Encyclopedia Britannica and the Astronomical Almanac for 1987.)

-- 
| Ray Lubinsky         Department of Computer Science, University of Virginia |
|                      UUCP:      ...!uunet!virginia!uvacs!rwl                |
|                      CSNET:     rwl@cs.virginia.edu                         |
|                      BITNET:    rwl8y@virginia                              |

dc@gcm (Dave Caswell) (11/15/87)

In article <6205@ihlpa.ATT.COM> rjh@ihlpa.UUCP (45261-Herber,R.J.) writes:
>I am including a program that computes the astronomical Julian Date
>using the Roman Catholic church's definition of when the switch
>between the Julian and the Georgian calendars occurred, i.e. Oct 4,
>1582 Old Style was followed by Oct 15, 1582 New Style.
>
Much complicated code follows.

I am including a version that couldn't care less when day one is; because
you will probably only be using it to find the number of days between two dates.

This is the code I use for "Julian dates".  Mail me if you can't, or don't
want to, write the inverse function(it's more than three lines).

julian(d, m, y)
int	d,m,y;
	if (m>2)
		return(1461 * y / 4 + 153 * (m+1) / 5 + d);
	return(1461 * (y-1) / 4 + 153 * (m+13) / 5 + d);
}