summaryrefslogtreecommitdiffstats
path: root/generic/tclClock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-15 06:34:43 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-15 06:34:43 (GMT)
commit8edd42396d9257bcc76b5457f3c49834ef2cb22b (patch)
tree5cc82c91dd4e5130d6abb30a7b66d5d1919cba57 /generic/tclClock.c
parent6e62967ee57a8ce0b804a5e6d103659722d56283 (diff)
parent7539841ffd6ed3122986a4aef9fc0b60e477c607 (diff)
downloadtcl-8edd42396d9257bcc76b5457f3c49834ef2cb22b.zip
tcl-8edd42396d9257bcc76b5457f3c49834ef2cb22b.tar.gz
tcl-8edd42396d9257bcc76b5457f3c49834ef2cb22b.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclClock.c')
-rw-r--r--generic/tclClock.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/generic/tclClock.c b/generic/tclClock.c
index 5d3caa1..336561a 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.