Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!umriscc!ee.umr.edu From: jmd@ee.umr.edu (Jim Dumser) Newsgroups: comp.binaries.ibm.pc.d Subject: Re: (Astronomical) Julian Date Source Wanted Message-ID: <2610@umriscc.isc.umr.edu> Date: 18 Apr 91 15:53:23 GMT References: <40790007@hpcvra.cv.hp.com.> <2609@umriscc.isc.umr.edu> Sender: news@umriscc.isc.umr.edu Organization: University of Missouri - Rolla Lines: 97 I've updated my code with the changes in Computer Language (Apr 91). Basically, it adds the capability to have different Gregorian starting days (in case you care) because different countries adopted the calendar at different times. My diffs follow. Jim PS - I still haven't found the patch in an issue between Dec 90 and Apr 91. I don't have all my issues with me, so if someone would look at those issues in the Feedback section, I'd appreciate it. It's not in Jan or Feb 91 (I checked them). Thanks. *** 1.1 1991/03/22 06:05:45 --- date.c 1991/04/18 15:45:25 *************** *** 3,8 **** --- 3,36 ---- #include "date.h" + #define YMD(d,m,y) ((y) * 10000.0 + (m) * 100.0 + (d)) + + /* + * store the first date when the Gregorian calendar was used: + * Belgium 21 Mar 1582 + * Portugal, Spain 15 Oct 1582 + * France 20 Dec 1582 + * Habsburg Empire 17 Jan 1584 + * Denmark, Norway 01 Mar 1700 + * Britain & colonies 14 Sep 1752 + * Finland 01 Mar 1753 + * + * Britain/American by default; use set_gregorian() to change + */ + static int g_year = 1752, g_month = 9, g_day = 14; + + int set_gregorian(int day, int month, int year) + { + int ok = valid_date(day, month, year); + + if (ok) { + g_year = year; g_month = month; g_day = day; + } + + return (ok); + } + + /* * Calculate the Julian day number for a specified day, month, and year. * B.C. years are negative. *************** *** 22,28 **** } /* cope with Gregorian calendar reform */ ! if (year * 10000.0 + month * 100.0 + day >= 15821015.0) { a = year / 100; b = 2 - a + a / 4; } --- 50,56 ---- } /* cope with Gregorian calendar reform */ ! if (YMD(day, month, year) >= YMD(g_day, g_month, g_year)) { a = year / 100; b = 2 - a + a / 4; } *************** *** 44,50 **** z = jdate + 1; /* cope with Gregorian calendar reform */ ! if (z < 2299161L) a = z; else { alpha = (long)((z - 1867216.25) / 36524.25); a = z + 1 + alpha - alpha / 4; --- 72,78 ---- z = jdate + 1; /* cope with Gregorian calendar reform */ ! if (z < julian_date(g_day, g_month, g_year) + 1) a = z; else { alpha = (long)((z - 1867216.25) / 36524.25); a = z + 1 + alpha - alpha / 4; *** 1.1 1991/03/22 06:05:45 --- date.h 1991/04/18 15:33:29 *************** *** 10,15 **** --- 10,16 ---- /* ANSI prototypes */ + int set_gregorian(int day, int month, int year); DATE julian_date(int day, int month, int year); void calendar_date(DATE jdate, int *day, int *month, int *year); int valid_date(int day, int month, int year);