Skip to content
Tcl Source Code History Of Ticket 2010909
Login

History Of Ticket 2010909

Artifacts Associated With Ticket 2010909

  1. Ticket change [3d88d36afd] (rid 121106) by haertel on 2008-07-04 19:54:12:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The clock scan command returns always the current week when the given format only contains the week (%V).
      
      test-case showing failure
      
      for {set week 0} {$week < 22} {incr week} { 
           set x [clock scan "$week 2008" -format "%V %Y"] 
           puts [clock format $x] 
      }
      
      However it works correctly when a week day is supplied.
      
      test-case workaround
      
       for {set week 0} {$week < 22} {incr week} { 
           set x [clock scan "$week Sun" -format "%V %A"] 
           puts [clock format $x] 
       
      }
      
      
      This could be a fix in the code. In that it assumes the current day.
      
      Or this could be a fix in the documentation. In that it is clearly stated that for the scan and format %V the week day shall be supplied to.
      
      
      From my point of view I'd prefer a fix in the code. Primarily because clock already assumes in the workaround that the year is the current year.
      
    4. foundin initialized to: "obsolete: 8.5.3"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "haertel"
    10. subsystem initialized to: "None"
    11. title initialized to: "clock scan fails with %V"
    12. type initialized to: "RFE"
  2. Ticket change [2a06d6e863] (rid 118483) by andreas_kupries on 2008-07-05 03:46:21:

    1. assignee changed to: "kennykb"
    2. subsystem changed to: "03. Timer Events"
  3. Ticket change [12ee0beb05] (rid 124136) by kennykb on 2008-07-05 05:02:41:

    1. closedate changed to: "2008-07-04T22:02:41"
    2. closer changed to: "kennykb"
    3. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      A careful reading of clock.n (under SCANNING TIMES) shows that
      [clock] here works as designed and documented.  I concede that
      the behaviour of ignoring the 'week' format group in that case
      is puzzling, but it fits with the fact that redundant groups
      are (and must be) ignored in other cases - for instance,
      in parsing an RFC2822 date, the day-of-the-week is presented
      even though the other fields are sufficient to specify the date.
      
      It is easy to parse a date like 2008-W27 if you need the
      start of the week:
      
      set date {2008-W27}
      set secs [clock scan "$date-1" -format "%G-%V-%u"]
      
      Another reason for the code to work the way it does is that
      otherwise there is also a possibility of nonsense combinations
      like "%G-%u" without a week number - either choosing a given
      weekday in the first week, or a given weekday in the current
      week number, would be surprising.
      
      
      
      
    4. login: "kennykb"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Pending"
    8. username: "kennykb"
  4. Ticket change [d451fbe403] (rid 123424) by ferrieux on 2008-07-05 06:36:22:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      Sorry, but I don't understand the reference to redundant groups: here we are on the other end of the spectrum -- underspecified rather than redundant. When we parse "2008 23" with "%Y %H" we get a similar situation, but the result is compatible with all specified data, it is a date whose time-of-day is 23:00 in year 2008. The same with %V violates the compatibility rule since it gives noon today, and today is not in week 01.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  5. Ticket change [20f1502b0e] (rid 130498) by kennykb on 2008-07-05 06:50:56:

    1. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      You're right, but...
      
      if underspecified ones are allowed from both ends, then an anomaly
      results with:
      
      2008-5 in place of 2008-W27-5
      
      or
      
      2008-04  in place of 2008-07-04
      
      Is that "a completely specified 2008 (meaning the start of the year)
      together with a redundant day of week or month"? 
      A completely specified "'day 4 of the current month' with
      a redundant year" or "'day 5 of the current week' with a
      redundant year"?
      "A specification that means day 4 of the month in 2008 corresponding
      with the base month" or "day 5 of the week in 2008 corresponding
      with the base week"?
      An error?
      Something else?
      
      Rather than worry about what the combination of under- and
      over-specified dates means, I punted, and said "there must
      be enough information in the specification to identify
      a unique day"
      
      I'm willing to revisit it, if someone wants to spec it out
      in a TIP.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  6. Ticket change [3e65ae5cd0] (rid 121264) by ferrieux on 2008-07-05 22:53:24:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      Hmm, you seem to be concentrating on under-specification of the input string, while I think it is useful to define it for the format string instead (the only circumstance under which "2008 04" should be reasoned about ex nihilo, is free-form-scanning. We are not in this case, we do have a format string.).
      
      Then, we can define the "compatibility principle" in a very simple fashion:
      
        [clock format [clock scan $s -format $f] -format $f]
        is always "nearly equal" to $s (except for whitespace
        and other irrelevant chars)
      
      This means that for "underspecified formats" like "%Y %V", [clock scan] is free to *choose* (as in "not specified") among several values, provided the above equation holds. This choice can be driven by simplicity of implementation, or by some objective function to optimize (like "closest to now").
      
      Kevin, don't you think this compatibility principle would be a good guide ?
      If we admit it, then clearly the current behavior with %V is a bug...
      (But please also notice that enforcing it would not require a TIP, since I can't imagine a purposeful use of "%Y %V" returning a date in the wrong week for example).
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  7. Ticket change [87a1d13180] (rid 131728) by kennykb on 2008-07-07 01:34:04:

    1. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      The cases that worry me are the ones that might
      be best described as "simultaneously overdetermined
      and underdetermined".  [clock scan] is documented to
      ignore excess fields - even if they are inconsistent.
      "7 juillet 2008 lundi" with format "%d %B %Y %A"
      and -locale fr parses correctly as 2008-07-07 even 
      though it is not a Monday. (This is much easier
      than attempting consistency checks for things like
      RFC2822 dates.)
      
      The issue then is one of determining which rule to
      apply when there are two sets of data, both underdetermined.
      Consider [clock scan "2008-1" -format "%G-%u"]
      That's one of the cases where I can't quite manage to
      figure out The Right Thing.  With your proposal, we
      have two incomplete data items: the year (which should
      then default to 1 January of that year), and the day
      of the week (which should default to Monday of the week
      of the base date).  What ought they to do in combination?
      Should one take precedence (if so, which?), or should this
      be an error, or is there another rule that should apply?
      
      
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. status changed to: "Open"
    5. username: "kennykb"
  8. Ticket change [d13a377f14] (rid 113312) by ferrieux on 2008-07-07 17:30:38:

    1. icomment:
      Logged In: YES 
      user_id=496139
      Originator: NO
      
      The idea is to think about format groups as constraints, hence each providing a (possibly large) *set* of solutions, instead of just a default value. Then the job of [clock scan] can be defined as returning *any* value within the intersection of all sets:
      
           "1993 4" / "%Y %V" --> any value on week 4 of 1993
      
      And again, picking a value in the intersection may be completely driven by the will of the implementor of [clock]. No value is worse than another in that respect !
      
      In the case of empty intersection (inconsistent fields like your example), it may use a predefined ordering of the constraints and return a value in the first nonempty intersection during relaxation:
      
            "7 juillet 2008 jeudi" / "%d %B %Y %A" -->
      
            predefined order of relaxation: %A..%d..%B..%Y
            first nonempty after relaxing: %A
            final intersection: %d,%B,%Y
      
      Tha above remark about "freedom of choice" means that
      
            [clock scan "2008-1" -format "%G-%u"]
      
      is free to return any monday of 2008. It currently returns the next Monday starting from today, which is a valid choice, just as would have been the first Monday of 2008. So I think your worries about The Right Thing are virtual...
      
      Do you have in mind a case breaking that compatibility principle ?
      
            
      
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [6e8908b78d] (rid 100161) by kennykb on 2008-07-31 01:23:59:

    1. foundin changed to: "None"
    2. icomment:
      
      
      data_type - 360894
      
      
      
    3. login: "kennykb"
    4. mimetype: "text/plain"
    5. resolution changed to: "None"
    6. subsystem changed to: "03. Timer Events"
    7. username: "kennykb"