Artifacts Associated With Ticket 482db1d796540e68
Ticket change [a8fab71537] (rid 238422) by sbron on 2025-03-11 14:25:38:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
I observe a wrong result from [clock add -631152000 2372806200 seconds]. This should obviously produce 1741654200 (-631152000 + 2372806200), but it returns 1741567800 instead.
- foundin initialized to: "2f1d68136a"
- is_private initialized to: "0"
- login: "sbron"
- priority initialized to: "5 Medium"
- private_contact initialized to: "8475f421649231f1e116ac602bea4537d2b027b4"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "sbron"
- subsystem initialized to: "16. Commands A-H"
- title initialized to:
Wrong result from simple clock arithmetic (clock add).
- type initialized to: "Bug"
Ticket change [d23721255d] (rid 238423) by sebres on 2025-03-11 17:41:13:
- foundin changed to: "8.7+"
- icomment:
The reason is a bug by porting <i><code>[clock add]</code></i> from Tcl to C - calculating seconds of day <code><nobr>localSeconds % SECONDS_PER_DAY</nobr></code> on a negative base generates negative result in C (-82800 instead of 3600 as it'd be in Tcl), so after all the seconds of day are wrong and the whole result deviate by one day: <code><pre> <span style="color:red;">- UTC -631152000 => LOCTM -631148400 % 86400 == <b>-82800</b></span> // C vs. <span style="color:green;">+ UTC -631152000 => LOCTM -631148400 % 86400 == <b> 3600</b></span> ## Tcl </pre></code> Fixing it now for 8.7+, add coverage, etc...
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
Ticket change [97c0105030] (rid 238435) by sebres on 2025-03-11 18:45:47:
- closedate changed to: "2460746.28180307"
- closer changed to: "sebres"
- icomment:
Basically fixed in [27cbd7afc65a5c79], but found more places for a compiler "fix" (signed-mod operation with potentially negative dividend), so added more corrections in [e33fcd57b0397d45] (including few code simplifications and normalizations). Test coverage is added too, so I close the ticket as fixed for now.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [45ef10d1c0] (rid 238436) by sebres on 2025-03-11 19:07:40:
- closedate changed to: "2460746.29700208"
- login: "sebres"
- mimetype: "text/plain"
- title changed to:
Wrong result from simple clock arithmetic (`clock add` with negative base).