Artifacts Associated With Ticket 1160695
Ticket change [542cf64fa5] (rid 93893) by dwcollins on 2005-03-10 15:36:22:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- 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? - foundin initialized to: "obsolete: 8.4.9"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dwcollins"
- subsystem initialized to: "16. Commands A-H"
- title initialized to: "clock scan "next wed" is wrong?"
- type initialized to: "Bug"
Ticket change [e91c6ad973] (rid 104754) by dkf on 2005-03-10 22:38:32:
- assignee changed to: "kennykb"
- subsystem changed to: "06. Time Measurement"
Ticket change [b5ee4ebfac] (rid 125333) by kennykb on 2005-03-15 23:05:03:
- 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.
- login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment:
Ticket change [c26467e1ed] (rid 111479) by kennykb on 2005-04-14 03:44:54:
- 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? - login: "kennykb"
- mimetype: "text/plain"
- username: "kennykb"
- icomment:
Ticket change [7f3679c8c4] (rid 97535) by kennykb on 2005-04-14 03:50:04:
- priority changed to: "4"
Ticket change [a3e59e41d3] (rid 110120) by dwcollins on 2005-04-14 17:12:00:
- 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).
- login: "dwcollins"
- mimetype: "text/plain"
- username: "dwcollins"
- icomment:
Ticket change [17f083888b] (rid 122582) by kennykb on 2005-04-19 22:22:23:
- closedate changed to: "2005-04-19T15:22:23"
- closer changed to: "kennykb"
- 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.
- login: "kennykb"
- mimetype: "text/plain"
- resolution changed to: "Wont Fix"
- status changed to: "Closed"
- username: "kennykb"