#4440 clock scan error

obsolete: 8.5.7
closed-wont-fix
5
2009-11-12
2009-10-20
David Zolli
No

% set start 1256421600
% clock format $start
Sun Oct 25 00:00:00 CEST 2009
% clock format [clock scan "[clock format $start] +24 hours"]
Sun Oct 25 23:00:00 CET 2009
% clock format [clock scan "[clock format $start] +1 day"]
Sun Oct 25 23:00:00 CET 2009
% clock format [clock scan "[clock format $start] +2 day"]
Mon Oct 26 23:00:00 CET 2009

The first clock scan command "could" be ok, but other results are wrong: at least one hour is missing (time switching from CEST to CET is probably the culprit).

the same thing but using [clock add] give good results.

Discussion

  • David Zolli

    David Zolli - 2009-10-20
    • assigned_to: dkf --> kennykb
     
  • Donal K. Fellows

    • labels: 105657 --> 06. Time Measurement
     
  • Kevin B KENNY

    Kevin B KENNY - 2009-10-29

    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

     
  • Kevin B KENNY

    Kevin B KENNY - 2009-10-29
    • milestone: --> obsolete: 8.5.7
    • status: open --> pending-wont-fix
     
  • SourceForge Robot

    • status: pending-wont-fix --> closed-wont-fix
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks