Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d23721255d36939066330c7feb8bfe4845e47b79569740dc21a1c05ae37d904b
Ticket: 482db1d796540e6865abdce17e2aa391f3fb88ff
Wrong result from simple clock arithmetic (`clock add` with negative base).
User & Date: sebres on 2025-03-11 17:41:13
Changes

  1. foundin changed to: "8.7+"
  2. 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...
    
  3. login: "sebres"
  4. mimetype: "text/x-fossil-wiki"