Skip to content
Tcl Source Code History Of Ticket 1160695fffffffffffffffffffffffffffffffff
Login

History Of Ticket 1160695fffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 1160695fffffffffffffffffffffffffffffffff

  1. Ticket change [542cf64fa5] (rid 93893) by dwcollins on 2005-03-10 15:36:22:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Using clock scan "next <dayname>" seems to go 2 
      weeks ahead, rather than 1, why is that? This affects 
      both the 8.4 line and 8.5.
      
      telhp6:/home/dcollins/tmp/tcl8.5a2/unix$ date
      Thu Mar 10 15:23:16 GMT 2005
      
      clock format [clock scan "+1 wed"] -format "%Y-%m-%
      d"
      2005-03-16
      clock format [clock scan "-1 wed"] -format "%Y-%m-%d"
      2005-03-09
      clock format [clock scan "next wed"] -format "%Y-%m-
      %d"
      2005-03-23
      clock format [clock scan "last wed"] -format "%Y-%m-%
      d"
      2005-03-09
      
      I can use +1 wed and -1 wed instead which seem to 
      work fine, but I mentally assumed that last/next was the 
      same as -1/+1, have I got it wrong?
      
      I tracked the "problem" to something in the yacc 
      grammer (Below). If I change the yyDayOrdinal to 1, 
      then I get the "correct" results, but it looks like it was 
      designed this way, so does the help need updating?
      
              | tNEXT tDAY {
                  yyDayOrdinal = 2;
                  yyDayNumber = $2;
              }
      
      This is probably obselete in 8.5 with the new clock 
      scan, but what's the equivalent 8.5 syntax?
      
      
    4. foundin initialized to: "obsolete: 8.4.9"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "dwcollins"
    9. subsystem initialized to: "16. Commands A-H"
    10. title initialized to: "clock scan "next wed" is wrong?"
    11. type initialized to: "Bug"
  2. Ticket change [e91c6ad973] (rid 104754) by dkf on 2005-03-10 22:38:32:

    1. assignee changed to: "kennykb"
    2. subsystem changed to: "06. Time Measurement"
  3. Ticket change [b5ee4ebfac] (rid 125333) by kennykb on 2005-03-15 23:05:03:

    1. icomment:
      Logged In: YES 
      user_id=99768
      
      In the [clock] grammar, "next Wednesday" is interpreted as
      "Wednesday week."  This is surely unexpected, but I'm afraid
      to change it at this late date, since it has always worked that
      way.
      
      And, lordy, you seem to have found a bit of a hole in the 8.5
      replacements - there doesn't seem to be a direct replacement
      for this. I probably need to add more stuff to [clock add]
      along the lines of [clock add $date 1 Wednesday]. Which
      will take another TIP. Oh, joy.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  4. Ticket change [c26467e1ed] (rid 111479) by kennykb on 2005-04-14 03:44:54:

    1. icomment:
      Logged In: YES 
      user_id=99768
      
      As I started writing a TIP for an enhancement to
      [clock add] to handle the case of "next wednesday"
      by a syntax like [clock add $date 1 Wednesday], I
      realized that such syntax, if localised, would open
      a can of worms in those locales where months and
      weekdays can have the same names (Mandarin Chinese
      has this problem, because both months and weekdays
      are simply known by their numbers.)
      
      But in hacking at the implementation, I realized
      that there is a (slightly awkward) way of
      approaching the problem:
      
        # Find the start of the current date
      
        set date [clock scan 0000 -format %H%m]
      
        # Find the start of Wednesday of the current
        # week, and advance to "next Wednesday"
      
        set wed [clock scan Wednesday \
                      -base $date -format %a]
        if { $wed <= $date } {
            set wed [clock add $wed 1 week]
        }
      
        # Alternatively, find the start of Wednesday
        # of the current week, and retreat to
        # "last Wednesday"
      
        set wed [clock scan Wednesday \
                       -base $date -format %a]
        if { $wed >= $date } {
            set wed [clock add $wed -1 week]
        }
      
      While this is a trifle more verbose than a simple
      [clock scan "next Wednesday"], it has the
      advantage that it will be correctly localised
      automatically (replace Wednesday with a day name
      in the locale specified by the -locale argument to
      [clock scan], and it'll still work), and it
      needs no additional magic in the 8.5 [clock]
      command to make it go.
      
      Is this usage acceptable?
      
      
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  5. Ticket change [7f3679c8c4] (rid 97535) by kennykb on 2005-04-14 03:50:04:

    1. priority changed to: "4"
  6. Ticket change [a3e59e41d3] (rid 110120) by dwcollins on 2005-04-14 17:12:00:

    1. icomment:
      Logged In: YES 
      user_id=1093010
      
      That looks reasonable to me. I hadn't realised that some 
      languages had the same syntax for days and months 
      (confusing or what!)
      
      Anyway, I managed to workaround it in 8.4, and your 8.5 
      solution is only a few lines (which the user could always wrap 
      up into a little procedure if they needed to), so I'd say go with 
      that.
      
      For 8.4 I ended up calculating the number of days to when I 
      wanted to poll and adding that to my time (kind of similar to 
      what you did with adding 1 week).
      
      
    2. login: "dwcollins"
    3. mimetype: "text/plain"
    4. username: "dwcollins"
  7. Ticket change [17f083888b] (rid 122582) by kennykb on 2005-04-19 22:22:23:

    1. closedate changed to: "2005-04-19T15:22:23"
    2. closer changed to: "kennykb"
    3. icomment:
      Logged In: YES 
      user_id=99768
      
      OK, since there is a "right way" to do it in 8.5, and fixing
      it is likely to break existing code in 8.4 (given that "it's
      always worked that way"), I'm closing the bug report.
      
      
    4. login: "kennykb"
    5. mimetype: "text/plain"
    6. resolution changed to: "Wont Fix"
    7. status changed to: "Closed"
    8. username: "kennykb"