[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible improvement of the date command
From: |
Paul Eggert |
Subject: |
Re: Possible improvement of the date command |
Date: |
11 Sep 2003 02:39:58 -0700 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
"Alexander Veit" <address@hidden> writes:
> I would suggest format specifiers to output the date as a julian
> date with and without day fraction, e.g.
>
> # date --date='2003-09-10' +%u
> 2452893
Only if you're 12 or more hours ahead of UTC; otherwise the correct
answer is 2452892. Or did you intend Julian dates to respect the time
zone? But the common practice is that they're always UTC.
The wonderful thing about Julian dates is that there are so many of them:
Julian Date (which starts at noon)
Julian Day (the floor of the Julian Date)
Modified Julian Date (which starts at midnight)
Truncated Julian Date
MJD = JD - 2400000.5
TJD = MJD - 40000
etc., etc. I think we'll run out of format letters before we can add
all the variants.
> Implementations may use the Jean Meeus or the Fliegel-Van Flandern
> algorithm.
I don't see why these would be needed.
Come to think of it, I don't see why 'date' needs to be modified at
all. Can't you just use "TZ=UTC0 date +%s", divide the result by
86400, and add the appropriate constant? That will let you easily
generate any of the above flavors of Julian date. (Unless you're
worried about leap seconds; but most sites don't have leap seconds.)