Re: Julian date function
This is a multi-part message in MIME format.
------=_NextPart_000_0179_01C72481.EE298CB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I think this function does in fact calculate the leap year correctly
according to the algorithm of the Julian calendar ...
Yes, you are of course correct, the Julian calender uses %4 for leap =
years,
for years after 4AD, whereas the Gregorian uses some extra conditions
(-%100, +%400, propossed -%4000).
However, seing as the dates they are working in are post Oct.04.1582 =
they
would be using a proleptic Julian calander, which, considering that =
they are
just calculating the day-of-year, doesn't make a lot of sense (to me =
at
least).
I can't think of much use for the Julian algorithm, but it might be a =
special requirement.
I would definitely want to clear this up with the customer!
That was the point i was going for ... and i guess missed. :)
For interest sake, here are two very short and easy-to-use routines you =
can build an entire date (class) library around. They're from way back =
in my C days. Though it's been many years since I've used them, I still =
marvel at these forumalas and give the author who calculated them great =
credit (he's a prestigious astronomer as I recall). I never would have =
come up with them myself. It works perfectly BTW (I once tested it for =
all possible dates in the supported range).
/////////////////////////////////////////////////////////////////////////=
///
// Name : jdn.c
//
// Description:
// Routines for processing dates in the format JDN (Julian Day =
Number).
// Based on formulae originally posted by Tom Van Flandern / =
Washington,
// DC / metares@well.sf.ca.us in the UseNet newsgroup sci.astro.
// Reposted 14 May 1991 in FidoNet C Echo conference by Paul =
Schlyter
// (Stockholm). Minor corrections, added JDN to julian, and recast =
into
// C by Raymond Gardner Englewood, Colorado.
//
// These routines convert Gregorian and Julian calendar dates to =
and
// from Julian Day Numbers. Julian Day Numbers (JDN) are used by
// astronomers as a date/time measure independent of calendars and
// convenient for computing the elapsed time between dates. The JDN
// for any date/time is the number of days (including fractional =
days)
// elapsed since noon, Jan 1, 4713 BC. Julian Day Numbers were =
originated
// by Joseph Scaliger in 1582 and named after his father Julius, =
not
// after Julius Caesar. They are not related to the Julian =
calendar.
// For dates from Jan 1, 4713 BC thru Feb 12, 32766 AD, =
"YMDToJDN()"
// will give the JDN for noon on that date. "JDNToYMD()" will =
compute
// the year, month, and day from the JDN. Years BC are given (and
// returned) as negative numbers. Note that there is no year 0 BC; =
the
// day before Jan 1, 1 AD is Dec 31, 1 BC. Also note that 1 BC, 5 =
BC,
// etc. are leap years.
//
// Pope Gregory XIII decreed that the Julian calendar would end on
// Oct 4, 1582 AD and that the next day would be Oct 15, 1582 in =
the
// Gregorian Calendar. The only other change is that centesimal =
years
// (years ending in 00) would no longer be leap years unless =
divisible
// by 400. Britain and its possessions and colonies continued to =
use
// the Julian calendar up until Sep 2, 1752, when the next day =
became
// Sep 14, 1752 in the Gregorian Calendar. These routines can be
// compiled to use either convention. By default, the British =
convention
// will be used. Simply #define PAPAL to use Pope Gregory's =
convention.
//
// Each routine takes, as its last argument, a flag to indicate =
whether
// to use the Julian or Gregorian calendar convention. If this flag =
is
// negative, the routines decide based on the date itself, using =
the
// changeover date described in the preceding paragraph. If the =
flag is
// zero, Gregorian conventions will be used, and if the flag is
// positive, Julian conventions will be used. Consult each function
// in the module for details.
//
// Development Environment:
// MSC V6.00, DOS 3.3
//
// Target Environment:
// Any (ANSI compatible)
//
// Change Control:
// Date Ver Who Ref Description
// Mar 17, 92 01.00.00 LS N/A Creation
/////////////////////////////////////////////////////////////////////////=
///
/////////////////////////////////////////////////////////////////////////=
///
// Constants
/////////////////////////////////////////////////////////////////////////=
///
#ifdef PAPAL // Pope Gregory XIII's decree ...
#define LASTJULDATE 15821004L // Last day to use Julian calendar
#define LASTJULJDN 2299160L // JDN equivalent of above
#else // British-American usage ...
#define LASTJULDATE 17520902L // Last day to use Julian calendar
#define LASTJULJDN 2361221L // JDN equivalent of above
#endif
/////////////////////////////////////////////////////////////////////////=
///
// typedefs
/////////////////////////////////////////////////////////////////////////=
///
typedef long JDN; // Julian Day Number
/////////////////////////////////////////////////////////////////////////=
///
// Name:
// YMDToJDN
//
// Description:
// As described in the module header, converts a date in the range
// Jan 1, 4713 BC to Feb 12, 32766 to its Julian Day Number (JDN).
// This function is the converse of "JDNToYMD()" defined elsewhere =
in
// the module. Note that no error checking is conducted by the =
function
// to ensure that the given date is valid.
//
// Input:
// iYear - Year in the range -4713 to 32766. Note that year 0 is
// invalid as described in the module header.
// iMonth - Month in the range 1 to 12
// iDay - Day of the month
// iJulian - As described in the module header, set to 1 if the =
Julian
// calendar is to be used, 0 if the Gregorian calendar is =
to
// be used, or -1 if the function decides this based on =
the
// date itself (again, see the module header for details).
// Note that most of the time, you will likely pass -1. =
Thus,
// the date you pass is assumed to be a Gregorian date if
// it falls past the Julian==>Gregorian changeover =
date
// described in the module header. Otherwise, if it falls =
on
// or before this changeover date, the date is assumed to =
be a
// Julian date.
//
// Output:
// None
//
// Return:
// The Julian Day Number for the given date.
//
// Comments:
// Note that the date you pass must be valid or erroneous results may
// occur. Thus, besides being a valid date (i.e., the year is not =
zero,
// the month is in the range 1-12, the day is in the range 1-31 and
// valid for the given month, etc.), care must be taken for those =
dates
// that fall inbetween the Julian==>Gregorian changeover dates =
described
// in the module header. Thus, for instance, since Britain and its
// possessions and colonies continued to use the Julian calendar up =
until
// Sep 2, 1752, where the next day became Sep 14, 1752, it makes =
little
// sense to pass a date inbetween this range (non-inclusive) if this =
date
// is intended to be a Gregorian date. It is a valid date however if
// the date is considered to be a Julian date (assumes no changeover
// to the Gregorian calendar for that date). The value returned by =
the
// function therefore varies according to the "iJulian" flag, =
returning
// the correct JDN regardless of the date (for its date type, either
// Julian or Gregorian).
//
/////////////////////////////////////////////////////////////////////////=
///
extern JDN YMDToJDN(int iYear, int iMonth, int iDay, int iJulian)
{
long lJDN;
if (iJulian < 0) // Set Julian flag if auto set
iJulian = (((iYear * 100L) + iMonth) * 100 + iDay <= =
LASTJULDATE);
if (iYear < 0) // Adjust BC year
iYear++;
if (iJulian)
{
lJDN = 367L * iYear - 7 * (iYear + 5001L + (iMonth - 9) / 7) / =
4
+ 275 * iMonth / 9 + iDay + 1729777L;
}
else
{
lJDN = (long)(iDay - 32076)
+ 1461L * (iYear + 4800L + (iMonth - 14) / 12) / 4
+ 367 * (iMonth - 2 - (iMonth - 14) / 12 * 12) / 12
- 3 * ((iYear + 4900L + (iMonth - 14) / 12) / 100) / 4
+ 1; // correction by rdg
}
return lJDN;
}
/////////////////////////////////////////////////////////////////////////=
///
// Name:
// JDNToYMD
//
// Description:
// As described in the module header, converts a Julian Day Number =
(JDN)
// in the range Jan 1, 4713 BC to Feb 12, 32766 to its equivlent =
year,
// month and day. This function is the converse of "YMDToJDN()" =
defined
// elsewhere in the module. Note that no error checking is conducted =
by
// the function to ensure that the given JDN is valid..
//
// Input:
// lJDN - Julian Day Number in the range Jan 1, 4713 BC to
// Feb 12, 32766.
// iJulian - As described in the module header, set to 1 if the =
Julian
// calendar is to be used, 0 if the Gregorian calendar is =
to
// be used, or -1 if the function decides this based on =
the
// date itself (again, see the module header for =
details).
// Note that most of the time, you will likely pass -1. =
Thus,
// the date you pass is assumed to be a Gregorian date if
// it falls past the Julian==>Gregorian changeover =
date
// described in the module header. Otherwise, if it falls =
on
// or before this changeover date, the date is assumed to =
be a
// Julian date.
//
// Output:
// piYear - Ignored if NULL. Otherwise, receives the year =
equivalent of
// the given JDN in the range -4713 to 32766. Note that =
year 0
// is invalid so this is NEVER returned.
// piMonth - Ignored if NULL. Otherwise, receives the month =
equivalent
// of the given JDN in the range 1 to 12.
// piDay - Ignored if NULL. Otherwise, receives the day of the =
month
// equivalent of the given JDN in the range 1 to 31
// (appropriate for the given month).
//
// Return:
// None
//
// Comments:
//
/////////////////////////////////////////////////////////////////////////=
///
extern void JDNToYMD(JDN lJDN, int *piYear, int *piMonth, int *piDay, =
int iJulian)
{
long x, z, m, d, y;
long lDaysPer400Years = 146097L;
long lFudgedDaysPer4000Years = 1460970L + 31;
if (iJulian < 0) // Set Julian flag if auto set
{
iJulian = (lJDN <= LASTJULJDN);
}
x = lJDN + 68569L;
if (iJulian)
{
x += 38;
lDaysPer400Years = 146100L;
lFudgedDaysPer4000Years = 1461000L + 1;
}
z = 4 * x / lDaysPer400Years;
x = x - (lDaysPer400Years * z + 3) / 4;
y = 4000 * (x + 1) / lFudgedDaysPer4000Years;
x = x - 1461 * y / 4 + 31;
m = 80 * x / 2447;
d = x - 2447 * m / 80;
x = m / 11;
m = m + 2 - 12 * x;
y = 100 * (z - 49) + y + x;
if (piYear)
{
*piYear = (int)y;
if (*piYear <= 0) // Adjust BC years */
{
(*piYear)--;
}
}
if (piMonth)
{
*piMonth = (int)m;
}
if (piDay)
{
*piDay = (int)d;
}
}
------=_NextPart_000_0179_01C72481.EE298CB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3020" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>>> I think this function does in =
fact
calculate the leap year correctly <BR>>> according to the =
algorithm of the
Julian calendar ...<BR>> <BR>> Yes, you are of course correct, the =
Julian
calender uses %4 for leap years, <BR>> for years after 4AD, whereas =
the
Gregorian uses some extra conditions <BR>> (-%100, +%400, propossed
-%4000).<BR>> <BR>> However, seing as the dates they are working =
in are
post Oct.04.1582 they <BR>> would be using a proleptic Julian =
calander,
which, considering that they are <BR>> just calculating the =
day-of-year,
doesn't make a lot of sense (to me at <BR>> least).<BR>> =
<BR>>> I
can't think of much use for the Julian algorithm, but it might be a =
<BR>>>
special requirement.<BR>>> I would definitely want to clear this =
up with
the customer!<BR>> <BR>> That was the point i was going for ... =
and i
guess missed. :)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=courier size=2>For interest sake, here are two =
very
short and easy-to-use routines you can build an entire date (class) =
library
around. They're from way back in my C days. Though it's been many years =
since
I've used them, I still marvel at these forumalas and give the author =
who
calculated them great credit (he's a prestigious astronomer as I =
recall). I
never would have come up with them myself. It works perfectly BTW (I =
once tested
it for all possible dates in the supported range).</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier
size=2>////////////////////////////////////////////////////////////////=
////////////<BR>//
Name : jdn.c<BR>//<BR>// =
Description:<BR>//
Routines for processing dates in the format JDN (Julian Day
Number).<BR>// Based on formulae =
originally posted
by Tom Van Flandern / Washington,<BR>// DC =
/
</FONT><A href="mailto:metares@well.sf.ca.us"><FONT face=courier
size=2>metares@well.sf.ca.us</FONT></A><FONT face=courier size=2> =
in the UseNet
newsgroup sci.astro.<BR>// Reposted 14 May =
1991 in
FidoNet C Echo conference by Paul =
Schlyter<BR>//
(Stockholm). Minor corrections, added JDN to julian, and recast
into<BR>// C by Raymond Gardner Englewood, =
Colorado.<BR>//<BR>// These routines =
convert
Gregorian and Julian calendar dates to =
and<BR>//
from Julian Day Numbers. Julian Day Numbers (JDN) are used
by<BR>// astronomers as a date/time =
measure
independent of calendars and<BR>// =
convenient for
computing the elapsed time between dates. The
JDN<BR>// for any date/time is the number =
of days
(including fractional days)<BR>// elapsed =
since
noon, Jan 1, 4713 BC. Julian Day Numbers were
originated<BR>// by Joseph Scaliger in =
1582 and
named after his father Julius, not<BR>// =
after
Julius Caesar. They are not related to the Julian
calendar.<BR>// For dates from Jan 1, 4713 =
BC thru
Feb 12, 32766 AD, "YMDToJDN()"<BR>// will =
give the
JDN for noon on that date. "JDNToYMD()" will
compute<BR>// the year, month, and day =
from the
JDN. Years BC are given (and<BR>// =
returned) as
negative numbers. Note that there is no year 0 BC;
the<BR>// day before Jan 1, 1 AD is Dec =
31, 1 BC.
Also note that 1 BC, 5 BC,<BR>// etc. are =
leap
years.<BR>//<BR>// Pope Gregory XIII =
decreed that
the Julian calendar would end on <BR>// =
Oct 4,
1582 AD and that the next day would be Oct 15, 1582 in the
<BR>// Gregorian Calendar. The only other =
change
is that centesimal years<BR>// (years =
ending in
00) would no longer be leap years unless
divisible<BR>// by 400. Britain and its
possessions and colonies continued to =
use<BR>//
the Julian calendar up until Sep 2, 1752, when the next day
became<BR>// Sep 14, 1752 in the Gregorian =
Calendar. These routines can be<BR>// =
compiled to
use either convention. By default, the British
convention<BR>// will be used. Simply =
#define
PAPAL to use Pope Gregory's convention.<BR>//
<BR>// Each routine takes, as its last =
argument, a
flag to indicate whether<BR>// to use the =
Julian
or Gregorian calendar convention. If this flag
is<BR>// negative, the routines decide =
based on
the date itself, using the<BR>// =
changeover date
described in the preceding paragraph. If the flag
is<BR>// zero, Gregorian conventions will =
be used,
and if the flag is<BR>// positive, Julian
conventions will be used. Consult each
function<BR>// in the module for
details.<BR>//<BR>// Development
Environment:<BR>// MSC V6.00, DOS
3.3<BR>//<BR>// Target =
Environment:<BR>//
Any (ANSI compatible)<BR>//<BR>// Change
Control:<BR>//
Date
Ver Who
Ref Description<BR>// Mar 17, =
92
01.00.00 LS N/A
Creation<BR>/////////////////////////////////////////////////////////////=
///////////////</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier
size=2>////////////////////////////////////////////////////////////////=
////////////<BR>//
Constants<BR>////////////////////////////////////////////////////////////=
////////////////<BR>#ifdef
PAPAL &n=
bsp;
// Pope Gregory XIII's decree ...<BR>#define LASTJULDATE =
15821004L
// Last day to use Julian calendar<BR>#define LASTJULJDN
2299160L // JDN equivalent of
above<BR>#else  =
; =
// British-American usage ...<BR>#define LASTJULDATE =
17520902L //
Last day to use Julian calendar<BR>#define LASTJULJDN
2361221L // JDN equivalent of =
above<BR>#endif</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier
size=2>////////////////////////////////////////////////////////////////=
////////////<BR>//
typedefs<BR>/////////////////////////////////////////////////////////////=
///////////////<BR>typedef
long JDN; // Julian Day Number</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier
size=2>////////////////////////////////////////////////////////////////=
////////////<BR>//
Name:<BR>// =
YMDToJDN<BR>//
<BR>// Description:<BR>// As described in the =
module
header, converts a date in the range <BR>// Jan =
1, 4713
BC to Feb 12, 32766 to its Julian Day Number
(JDN).<BR>// This function is the converse of
"JDNToYMD()" defined elsewhere in<BR>// the =
module. Note
that no error checking is conducted by the
function<BR>// to ensure that the given date is
valid.<BR>//<BR>// Input:<BR>// =
iYear - Year
in the range -4713 to 32766. Note that year 0
is<BR>//  =
;
invalid as described in the module header.<BR>// =
iMonth - Month in the range 1 to 12<BR>//
iDay - Day of the month<BR>// =
iJulian
- As described in the module header, set to 1 if the
Julian<BR>// &=
nbsp;
calendar is to be used, 0 if the Gregorian calendar is
to<BR>//  =
;
be used, or -1 if the function decides this based on
the<BR>// &nbs=
p;
date itself (again, see the module header for
details).<BR>// &nbs=
p;
Note that most of the time, you will likely pass -1.
Thus,<BR>// &n=
bsp;
the date you pass is assumed to be a Gregorian date
if<BR>//  =
;
it falls past the Julian==>Gregorian changeover
date<BR>// &nb=
sp;
described in the module header. Otherwise, if it falls
on<BR>//  =
;
or before this changeover date, the date is assumed to be
a<BR>// =
Julian date.<BR>//<BR>// Output:<BR>// =
None<BR>//<BR>//
Return:<BR>// The Julian Day Number for the given
date.<BR>//<BR>// Comments:<BR>// Note that the date =
you pass
must be valid or erroneous results may<BR>// occur. =
Thus,
besides being a valid date (i.e., the year is not =
zero,<BR>//
the month is in the range 1-12, the day is in the range 1-31
and<BR>// valid for the given month, etc.), care must =
be taken
for those dates<BR>// that fall inbetween the
Julian==>Gregorian changeover dates =
described<BR>// in the
module header. Thus, for instance, since Britain and =
its<BR>//
possessions and colonies continued to use the Julian calendar up
until<BR>// Sep 2, 1752, where the next day became Sep =
14,
1752, it makes little<BR>// sense to pass a date =
inbetween
this range (non-inclusive) if this date<BR>// is =
intended to
be a Gregorian date. It is a valid date however =
if<BR>// the
date is considered to be a Julian date (assumes no
changeover<BR>// to the Gregorian calendar for that =
date). The
value returned by the<BR>// function therefore varies
according to the "iJulian" flag, returning<BR>// the =
correct
JDN regardless of the date (for its date type, =
either<BR>//
Julian or
Gregorian).<BR>//<BR>////////////////////////////////////////////////////=
////////////////////////<BR>extern
JDN YMDToJDN(int iYear, int iMonth, int iDay, int
iJulian)<BR>{<BR> long lJDN;</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if (iJulian <
0) // Set Julian flag if auto
set<BR> iJulian = (((iYear * =
100L) +
iMonth) * 100 + iDay <= LASTJULDATE);</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if (iYear < =
0)
// Adjust BC year<BR>
iYear++;</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if
(iJulian)<BR> =
{<BR>
lJDN = 367L * iYear - 7 * (iYear + 5001L + (iMonth - 9) / 7) /
4<BR> + 275 * iMonth / 9 + =
iDay +
1729777L;<BR> }<BR>
else<BR> =
{<BR> lJDN
= (long)(iDay - 32076)<BR> + =
1461L *
(iYear + 4800L + (iMonth - 14) / 12) /
4<BR> + 367 * (iMonth - 2 - =
(iMonth -
14) / 12 * 12) / 12<BR> - 3 * =
((iYear
+ 4900L + (iMonth - 14) / 12) / 100) /
4<BR> + 1; // =
correction
by rdg<BR> }</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> return =
lJDN;<BR>}</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier
size=2>////////////////////////////////////////////////////////////////=
////////////<BR>//
Name:<BR>// =
JDNToYMD<BR>//
<BR>// Description:<BR>// As described in the =
module
header, converts a Julian Day Number (JDN)<BR>// =
in the
range Jan 1, 4713 BC to Feb 12, 32766 to its equivlent
year,<BR>// month and day. This function is the =
converse
of "YMDToJDN()" defined<BR>// elsewhere in the =
module.
Note that no error checking is conducted =
by<BR>// the
function to ensure that the given JDN is valid..<BR>//<BR>//
Input:<BR>// lJDN - =
Julian Day
Number in the range Jan 1, 4713 BC
to<BR>//  =
;
Feb 12, 32766.<BR>// iJulian - As =
described in the
module header, set to 1 if the
Julian<BR>// &=
nbsp;
calendar is to be used, 0 if the Gregorian calendar is
to<BR>//  =
;
be used, or -1 if the function decides this based on
the<BR>// &nbs=
p;
date itself (again, see the module header for
details).<BR>// &nbs=
p;
Note that most of the time, you will likely pass -1.
Thus,<BR>// &n=
bsp;
the date you pass is assumed to be a Gregorian date
if<BR>//  =
;
it falls past the Julian==>Gregorian changeover
date<BR>// &nb=
sp;
described in the module header. Otherwise, if it falls
on<BR>//  =
;
or before this changeover date, the date is assumed to be
a<BR>// =
Julian date.<BR>//<BR>// Output:<BR>//
piYear - Ignored if NULL. Otherwise, receives the year =
equivalent
of<BR>//  =
;
the given JDN in the range -4713 to 32766. Note that year
0<BR>// =
is invalid so this is NEVER returned.<BR>//
piMonth - Ignored if NULL. Otherwise, receives the month
equivalent<BR>// &nb=
sp;
of the given JDN in the range 1 to 12.<BR>//
piDay - Ignored if NULL. Otherwise, receives the day =
of the
month<BR>// &n=
bsp;
equivalent of the given JDN in the range 1 to
31<BR>//  =
;
(appropriate for the given month).<BR>//<BR>//
Return:<BR>// None<BR>//<BR>//
Comments:<BR>//<BR>//////////////////////////////////////////////////////=
//////////////////////<BR>extern
void JDNToYMD(JDN lJDN, int *piYear, int *piMonth, int *piDay, int
iJulian)<BR>{<BR> long x, z, m, d, =
y;<BR>
long lDaysPer400Years = 146097L;<BR> long
lFudgedDaysPer4000Years = 1460970L + 31;</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if (iJulian <
0) // Set Julian flag if auto set<BR>
{<BR> iJulian = (lJDN =
<=
LASTJULJDN);<BR> }</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> x = lJDN +
68569L;<BR> if (iJulian)<BR>
{<BR> x +=
38;<BR> lDaysPer400Years =
146100L;<BR> =
lFudgedDaysPer4000Years =
1461000L + 1;<BR> }<BR> z = 4 * x =
/
lDaysPer400Years;<BR> x = x - (lDaysPer400Years * z =
+ 3) /
4;<BR> y = 4000 * (x + 1) /
lFudgedDaysPer4000Years;<BR> x = x - 1461 * y / 4 +
31;<BR> m = 80 * x / 2447;<BR> d =
= x - 2447
* m / 80;<BR> x = m / 11;<BR> m =
= m + 2 - 12
* x;<BR> y = 100 * (z - 49) + y + x;</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if
(piYear)<BR> =
{<BR>
*piYear = (int)y;<BR> if =
(*piYear
<= 0) // Adjust BC years
*/<BR>
{<BR>
(*piYear)--;<BR>
}<BR> }</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if
(piMonth)<BR> =
{<BR>
*piMonth = (int)m;<BR> }</FONT></DIV>
<DIV><FONT face=courier size=2></FONT> </DIV>
<DIV><FONT face=courier size=2> if
(piDay)<BR> =
{<BR>
*piDay = (int)d;<BR> =
}<BR>}<BR></FONT></DIV></BODY></HTML>
------=_NextPart_000_0179_01C72481.EE298CB0--