home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
qtawk
/
date.exp
< prev
next >
Wrap
Text File
|
1990-04-23
|
1KB
|
40 lines
# QTAwk utility functions for computing Julian Day Number from calender date
# and reverse
# (C) Copyright 1990 Terry D. Boldt, All Rights Reserved
# gregorian/julian calender flag.
# TRUE == julian
# FALSE == gregorian --> current calender system
#
# greg_jul = FALSE; # --> current calender system
# function to convert year/month/day into julian day number
function jdn(year,month,day) {
local yr;
local pfac = 0.6;
local ljdn;
yr = year + (month - 3.0) / 12.0;
ljdn = int(367.0 * yr + pfac) - (2 * int(yr)) + int(yr/4.0)
+ int(day) + 1721117;
if ( !greg_jul ) ljdn += -int(yr/100.0) + int(yr/400.0) + 2;
return ljdn;
}
# function to convert jdn to yr/mo/dy.
function _caln(cjdn,date) {
local n, ic, np, npp, mp;
n = int(cjdn) - 1721119;
ic = (n - 0.2)/36524.25;
if ( greg_jul ) np = n + 2; else np = n + ic - (ic / 4L);
date[1] = int((np - 0.2)/365.25);
npp = np - int(365.25 * date[1]);
mp = (npp - 0.5)/30.6;
date[3] = int(npp + 0.5 - 30.6 * mp);
if ( mp <= 9 ) date[2] = mp + 3;
else {
date[1] += 1.0;
date[2] = mp - 9;
}
}