Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2c563bd9756f7df45f5289405f234b361b9b2e1f
Ticket: 2882209fffffffffffffffffffffffffffffffff
clock scan error
User & Date: kennykb on 2009-10-29 07:40:20
Changes

  1. icomment:
    This is an example of why [clock scan] without a '-format' is so very nasty.
    
    When you do [clock format [clock scan "[clock format $start] + 1 day"]], what that winds up asking [clock scan] to parse is the string:
    
    Sun Oct 25 23:00:00 CEST 2009 + 1 day
    
    All goes well with parsing, and we get:
    
    year 2009 month 10 day 25 time of day 00:00:00 + 1 day timezone CEST
    
    Adjusting the date by 1 day gives
    
    year 2009 month 10 day 26 time of day 00:00:00 timezone CEST
    
    And - CEST is still in effect here- because it's specified explicitly as the timezone!
    So even though the specified time is after the Summer Time->Standard Time conversion, it's interpreted in Summer Time and results in a time that's an hour off.
    
    But if we try to fix this, it would break the case where we have an input string with a timezone other than the system timezone:
    
    Sun Oct 25 00:00:00 EDT 2009
    
    As I mentioned earlier, [clock add] will work.  If you need 8.4 compatibility, probably the best option is:
    
    clock format [clock scan {+1 day} -base $start]
    
    which also gets the right answer, and is shorter and simpler than what you've tried.
    
    Also, using any format without a timezone in the inner [clock format] works.
    
    % clock format [clock scan "+1 day" -base $start]
    Mon Oct 26 00:00:00 CET 2009
    % clock format [clock scan "[clock format $start -format {%Y-%m-%d %H:%M:%S}] +1 day"]
    Mon Oct 26 00:00:00 CET 2009
    
    
  2. login: "kennykb"
  3. mimetype: "text/plain"
  4. username: "kennykb"