Skip to content
Tcl Source Code Artifact [c26467e1ed]
Login

Artifact [c26467e1ed]

Artifact c26467e1edabc1a96045998891733b911dfd2062:

Ticket change [c26467e1ed] - Ticket [1160695fffffffff|1160695fff] <i>clock scan &quot;next wed&quot; is wrong?</i> status still Open with 4 other changes by kennykb on 2005-04-14 03:44:54.
D 2005-04-14T03:44:54
J icomment Logged\sIn:\sYES\s\nuser_id=99768\n\nAs\sI\sstarted\swriting\sa\sTIP\sfor\san\senhancement\sto\n[clock\sadd]\sto\shandle\sthe\scase\sof\s"next\swednesday"\nby\sa\ssyntax\slike\s[clock\sadd\s$date\s1\sWednesday],\sI\nrealized\sthat\ssuch\ssyntax,\sif\slocalised,\swould\sopen\na\scan\sof\sworms\sin\sthose\slocales\swhere\smonths\sand\nweekdays\scan\shave\sthe\ssame\snames\s(Mandarin\sChinese\nhas\sthis\sproblem,\sbecause\sboth\smonths\sand\sweekdays\nare\ssimply\sknown\sby\stheir\snumbers.)\n\nBut\sin\shacking\sat\sthe\simplementation,\sI\srealized\nthat\sthere\sis\sa\s(slightly\sawkward)\sway\sof\napproaching\sthe\sproblem:\n\n\s\s#\sFind\sthe\sstart\sof\sthe\scurrent\sdate\n\n\s\sset\sdate\s[clock\sscan\s0000\s-format\s%H%m]\n\n\s\s#\sFind\sthe\sstart\sof\sWednesday\sof\sthe\scurrent\n\s\s#\sweek,\sand\sadvance\sto\s"next\sWednesday"\n\n\s\sset\swed\s[clock\sscan\sWednesday\s\\\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s-base\s$date\s-format\s%a]\n\s\sif\s{\s$wed\s<=\s$date\s}\s{\n\s\s\s\s\s\sset\swed\s[clock\sadd\s$wed\s1\sweek]\n\s\s}\n\n\s\s#\sAlternatively,\sfind\sthe\sstart\sof\sWednesday\n\s\s#\sof\sthe\scurrent\sweek,\sand\sretreat\sto\n\s\s#\s"last\sWednesday"\n\n\s\sset\swed\s[clock\sscan\sWednesday\s\\\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s-base\s$date\s-format\s%a]\n\s\sif\s{\s$wed\s>=\s$date\s}\s{\n\s\s\s\s\s\sset\swed\s[clock\sadd\s$wed\s-1\sweek]\n\s\s}\n\nWhile\sthis\sis\sa\strifle\smore\sverbose\sthan\sa\ssimple\n[clock\sscan\s"next\sWednesday"],\sit\shas\sthe\nadvantage\sthat\sit\swill\sbe\scorrectly\slocalised\nautomatically\s(replace\sWednesday\swith\sa\sday\sname\nin\sthe\slocale\sspecified\sby\sthe\s-locale\sargument\sto\n[clock\sscan],\sand\sit'll\sstill\swork),\sand\sit\nneeds\sno\sadditional\smagic\sin\sthe\s8.5\s[clock]\ncommand\sto\smake\sit\sgo.\n\nIs\sthis\susage\sacceptable?\n\n\n
J login kennykb
J mimetype text/plain
J username kennykb
K 1160695fffffffffffffffffffffffffffffffff
U kennykb
Z 414ae23803e5f1efbe85e140cfb7a7b6