diff options
author | sebres <sebres@users.sourceforge.net> | 2019-01-25 20:18:09 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2019-01-25 20:18:09 (GMT) |
commit | 5846943d27d4aa4f79753cda4526efdbae5f00d3 (patch) | |
tree | 0dfc3f7a34a17c6bc82831b01e7164f4263d8785 /generic/tclDate.h | |
parent | ec6bc3e8fc49444829d56dfd699dd84bd27331fc (diff) | |
download | tcl-5846943d27d4aa4f79753cda4526efdbae5f00d3.zip tcl-5846943d27d4aa4f79753cda4526efdbae5f00d3.tar.gz tcl-5846943d27d4aa4f79753cda4526efdbae5f00d3.tar.bz2 |
fixes [16e4fc3096] julian day calculation (mostly affected for very small times, B.C.E. between 4714 and 4713), added test-cases covering that.
Diffstat (limited to 'generic/tclDate.h')
-rw-r--r-- | generic/tclDate.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/generic/tclDate.h b/generic/tclDate.h index 9aa031a..2751ee5 100644 --- a/generic/tclDate.h +++ b/generic/tclDate.h @@ -476,6 +476,31 @@ struct ClockFmtScnStorage { #endif }; +/* + * Clock macros. + */ + +/* + * Extracts Julian day and seconds of the day from posix seconds (tm). + */ +#define ClockExtractJDAndSODFromSeconds(jd, sod, tm) \ + if (1) { \ + jd = (tm + JULIAN_SEC_POSIX_EPOCH); \ + if (jd >= SECONDS_PER_DAY || jd <= -SECONDS_PER_DAY) { \ + jd /= SECONDS_PER_DAY; \ + sod = (int)(tm % SECONDS_PER_DAY); \ + } else { \ + sod = (int)jd, jd = 0; \ + } \ + if (sod < 0) { \ + sod += SECONDS_PER_DAY; \ + /* JD is affected, if switched into negative (avoid 24 hours difference) */ \ + if (jd <= 0) { \ + jd--; \ + } \ + } \ + } + /* * Prototypes of module functions. */ |