diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclClock.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c index 39fb073..4f97cb9 100644 --- a/generic/tclClock.c +++ b/generic/tclClock.c @@ -447,11 +447,13 @@ ClockGetdatefieldsObjCmd( } /* - * Extract Julian day. + * Extract Julian day. Always round the quotient down by subtracting 1 + * when the remainder is negative (i.e. if the quotient was rounded up). */ - fields.julianDay = (int) ((fields.localSeconds + JULIAN_SEC_POSIX_EPOCH) - / SECONDS_PER_DAY); + fields.julianDay = (int) ((fields.localSeconds / SECONDS_PER_DAY) - + ((fields.localSeconds % SECONDS_PER_DAY) < 0) + + JULIAN_DAY_POSIX_EPOCH); /* * Convert to Julian or Gregorian calendar. |