Tcl Source Code

Artifact [fc8982924f]
Login

Artifact fc8982924f6b00455b577f69100a3de1f46f4fdc:

Ticket change [fc8982924f] - Ticket [5f71353740] [patch] support the "weekdays" unit in [clock add] status still Open with 3 other changes by gahr 2013-11-20 13:50:03.
D 2013-11-20T13:50:03.790
J icomment <verbatim>\r\nIndex:\sdoc/clock.n\r\n==================================================================\r\n---\sdoc/clock.n\r\n+++\sdoc/clock.n\r\n@@\s-87,14\s+87,13\s@@\r\n\sback\sin\ssync\swith\sUTC;\sits\sdata\smodel\sdoes\snot\srepresent\sminutes\sthat\r\n\shave\s59\sor\s61\sseconds.\r\n\s.TP\r\n\s\\fIunit\\fR\r\n\sOne\sof\sthe\swords,\s\\fBseconds\\fR,\s\\fBminutes\\fR,\s\\fBhours\\fR,\r\n-\\fBdays\\fR,\s\\fBweeks\\fR,\s\\fBmonths\\fR,\sor\s\\fByears\\fR,\sor\r\n-any\sunique\sprefix\sof\ssuch\sa\sword.\sUsed\sin\sconjunction\swith\s\\fIcount\\fR\r\n-to\sidentify\san\sinterval\sof\stime,\sfor\sexample,\s\\fI3\sseconds\\fR\sor\r\n-\\fI1\syear\\fR.\r\n+\\fBdays\\fR,\s\\fBweekdays\\fR,\s\\fBweeks\\fR,\s\\fBmonths\\fR,\sor\s\\fByears\\fR.\r\n+Used\sin\sconjunction\swith\s\\fIcount\\fR\sto\sidentify\san\sinterval\sof\stime,\r\n+for\sexample,\s\\fI3\sseconds\\fR\sor\s\\fI1\syear\\fR.\r\n\s.SS\s"OPTIONS"\r\n\s.TP\r\n\s\\fB\\-base\\fR\stime\r\n\sSpecifies\sthat\sany\srelative\stimes\spresent\sin\sa\s\\fBclock\sscan\\fR\scommand\r\n\sare\sto\sbe\sgiven\srelative\sto\s\\fItime\\fR.\s\s\\fItime\\fR\smust\sbe\sexpressed\sas\r\n@@\s-173,12\s+172,11\s@@\r\n\s(expressed\sas\snominal\sseconds\sfrom\sthe\sepoch\stime\sof\s1\sJanuary\s1970,\s00:00\sUTC)\r\n\sgiven\sas\sits\sfirst\sargument.\s\sThe\sremaining\sarguments\s(other\sthan\sthe\r\n\spossible\s\\fB\\-timezone\\fR,\s\\fB\\-locale\\fR\sand\s\\fB\\-gmt\\fR\soptions)\r\n\sare\sintegers\sand\skeywords\sin\salternation,\swhere\sthe\skeywords\sare\schosen\r\n\sfrom\s\\fBseconds\\fR,\s\\fBminutes\\fR,\s\\fBhours\\fR,\r\n-\\fBdays\\fR,\s\\fBweeks\\fR,\s\\fBmonths\\fR,\sor\s\\fByears\\fR,\sor\r\n-any\sunique\sprefix\sof\ssuch\sa\sword.\r\n+\\fBdays\\fR,\s\\fBweekdays\\fR,\s\\fBweeks\\fR,\s\\fBmonths\\fR,\sor\s\\fByears\\fR.\r\n\s.PP\r\n\sAddition\sof\sseconds,\sminutes\sand\shours\sis\sfairly\sstraightforward;\r\n\sthe\sgiven\stime\sincrement\s(times\ssixty\sfor\sminutes,\sor\s3600\sfor\shours)\r\n\sis\ssimply\sadded\sto\sthe\s\\fItimeVal\\fR\sgiven\r\n\sto\sthe\s\\fBclock\sadd\\fR\scommand.\s\sThe\sresult\sis\sinterpreted\sas\r\n@@\s-211,11\s+209,12\s@@\r\n\sAdding\sand\ssubtracting\sdays\sand\sweeks\sis\saccomplished\sby\sconverting\r\n\sthe\sgiven\stime\sto\sa\scalendar\sday\sand\stime\sof\sday\sin\sthe\sappropriate\r\n\stime\szone\sand\slocale.\s\sThe\srequisite\snumber\sof\sdays\s(weeks\sare\sconverted\r\n\sto\sdays\sby\smultiplying\sby\sseven)\sis\sadded\sto\sthe\scalendar\sday,\sand\r\n\sthe\sdate\sand\stime\sare\sthen\sconverted\sback\sto\sa\scount\sof\sseconds\sfrom\r\n-the\sepoch\stime.\r\n+the\sepoch\stime.\s\sThe\s\\fBweekdays\\fR\skeyword\sis\ssimilar\sto\s\\fBdays\\fR,\r\n+with\sthe\sonly\sdifference\sthat\sweekends\sare\sskipped.\r\n\s.PP\r\n\sAdding\sand\ssubtracting\sa\sgiven\snumber\sof\sdays\sacross\sthe\spoint\sthat\r\n\sthe\stime\schanges\sat\sthe\sstart\sor\send\sof\ssummer\stime\s(Daylight\sSaving\sTime)\r\n\sresults\sin\sthe\s\\fIsame\slocal\stime\\fR\son\sthe\sday\sin\squestion.\s\sFor\r\n\sinstance,\sthe\sfollowing\scode\ssets\sthe\svalue\sof\s\\fBx\\fR\sto\s\\fB05:00:00\\fR.\r\n\r\nIndex:\slibrary/clock.tcl\r\n==================================================================\r\n---\slibrary/clock.tcl\r\n+++\slibrary/clock.tcl\r\n@@\s-4269,11\s+4269,11\s@@\r\n\s\t\s\s\s\s"wrong\s\\#\sargs:\sshould\sbe\\\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\\"$cmdName\sclockval\s?number\sunits?...\\\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s?-gmt\sboolean?\s?-locale\sLOCALE?\s?-timezone\sZONE?\\""\r\n\s\s\s\s\s}\r\n\s\s\s\s\sif\s{\s[catch\s{\sexpr\s{wide($clockval)}\s}\sresult]\s}\s{\r\n-\treturn\s-code\serror\s$result\r\n+\treturn\s-code\serror\s"expected\sinteger\sbut\sgot\s\\"$clockval\\""\r\n\s\s\s\s\s}\r\n\s\r\n\s\s\s\s\sset\soffsets\s{}\r\n\s\s\s\s\sset\sgmt\s0\r\n\s\s\s\s\sset\slocale\sc\r\n@@\s-4308,13\s+4308,10\s@@\r\n\s\s\s\s\sif\s{\s[info\sexists\ssaw(-gmt)]\s&&\s[info\sexists\ssaw(-timezone)]\s}\s{\r\n\s\treturn\s-code\serror\s\\\r\n\s\t\s\s\s\s-errorcode\s[list\sCLOCK\sgmtWithTimezone]\s\\\r\n\s\t\s\s\s\s"cannot\suse\s-gmt\sand\s-timezone\sin\ssame\scall"\r\n\s\s\s\s\s}\r\n-\s\s\s\sif\s{\s[catch\s{\sexpr\s{\swide($clockval)\s}\s}\sresult]\s}\s{\r\n-\treturn\s-code\serror\s"expected\sinteger\sbut\sgot\s\\"$clockval\\""\r\n-\s\s\s\s}\r\n\s\s\s\s\sif\s{\s![string\sis\sboolean\s-strict\s$gmt]\s}\s{\r\n\s\treturn\s-code\serror\s"expected\sboolean\svalue\sbut\sgot\s\\"$gmt\\""\r\n\s\s\s\s\s}\selseif\s{\s$gmt\s}\s{\r\n\s\tset\stimezone\s:GMT\r\n\s\s\s\s\s}\r\n@@\s-4346,10\s+4343,15\s@@\r\n\s\t\t}\r\n\s\t\tdays\s-\sday\s{\r\n\s\t\t\s\s\s\sset\sclockval\s[AddDays\s$quantity\s$clockval\s$timezone\s\\\r\n\s\t\t\t\s\s\s\s$changeover]\r\n\s\t\t}\r\n+\r\n+\t\tweekdays\s-\sweekday\s{\r\n+\t\t\s\s\s\sset\sclockval\s[AddWeekDays\s$quantity\s$clockval\s$timezone\s\\\r\n+\t\t\t\s\s\s\s$changeover]\r\n+\t\t}\r\n\s\r\n\s\t\thours\s-\shour\s{\r\n\s\t\t\s\s\s\sset\sclockval\s[expr\s{\s3600\s*\s$quantity\s+\s$clockval\s}]\r\n\s\t\t}\r\n\s\t\tminutes\s-\sminute\s{\r\n@@\s-4448,10\s+4450,47\s@@\r\n\s\s\s\s\sset\sdate\s[ConvertLocalToUTC\s$date[set\sdate\s{}]\s$TZData($timezone)\s\\\r\n\s\t\t\s$changeover]\r\n\s\r\n\s\s\s\s\sreturn\s[dict\sget\s$date\sseconds]\r\n\s}\r\n+\r\n+#----------------------------------------------------------------------\r\n+#\r\n+#\sAddWeekDays\s--\r\n+#\r\n+#\tAdd\sa\sgiven\snumber\sof\sweek\sdays\s(skipping\sSaturdays\sand\sSundays)\r\n+#\tto\sa\sgiven\sclock\svalue\sin\sa\sgiven\stime\szone.\r\n+#\r\n+#\sParameters:\r\n+#\tdays\s-\sNumber\sof\sdays\sto\sadd\s(may\sbe\snegative)\r\n+#\tclockval\s-\sSeconds\ssince\sthe\sepoch\sbefore\sthe\soperation\r\n+#\ttimezone\s-\sTime\szone\sin\swhich\sthe\soperation\sis\sto\sbe\sperformed\r\n+#\tchangeover\s-\sJulian\sDay\son\swhich\sthe\sGregorian\scalendar\swas\sadopted\r\n+#\t\t\s\s\s\s\sin\sthe\starget\slocale.\r\n+#\r\n+#\sResults:\r\n+#\tReturns\sthe\snew\sclock\svalue\sas\sa\snumber\sof\sseconds\ssince\sthe\sepoch.\r\n+#\r\n+#\sSide\seffects:\r\n+#\tNone.\r\n+#\r\n+#----------------------------------------------------------------------\r\n+proc\s::tcl::clock::AddWeekDays\s{\sdays\sclockval\stimezone\schangeover\s}\s{\r\n+\r\n+\s\s\s\sset\sday\s[format\s$clockval\s-format\s%u]\r\n+\r\n+\s\s\s\sset\sweeks\s\s[expr\s{$days\s/\s5}]\r\n+\s\s\s\sset\srdays\s\s[expr\s{$days\s%\s5}]\r\n+\s\s\s\sset\stoAdd\s\s[expr\s{7\s*\s$weeks\s+\s$rdays}]\r\n+\s\s\s\sset\sresDay\s[expr\s{$day\s+\s($toAdd\s%\s7)}]\r\n+\s\s\s\sif\s{$resDay\s>\s5}\s{\r\n+\s\s\s\s\s\s\s\sincr\stoAdd\s2\r\n+\s\s\s\s}\r\n+\r\n+\s\s\s\sAddDays\s$toAdd\s$clockval\s$timezone\s$changeover\r\n+}\r\n+\r\n\s\r\n\s#----------------------------------------------------------------------\r\n\s#\r\n\s#\sAddDays\s--\r\n\s#\r\n\r\nIndex:\stests/clock.test\r\n==================================================================\r\n---\stests/clock.test\r\n+++\stests/clock.test\r\n@@\s-34990,10\s+34990,14\s@@\r\n\s\s\s\s\s\s\s\s\s-gmt\strue\s-locale\sen_US_roman\s\\\r\n\s\s\s\s\s\s\s\s\s-format\s{%J\s%Ol:%OM:%OS\s%P}\r\n\s}\s86399\r\n\s#\sEND\stestcases29\r\n\s\r\n+\r\n+#\sBEGIN\stestcases30\r\n+\r\n+#\sTest\s[clock\sadd]\r\n\stest\sclock-30.1\s{clock\sadd\syears}\s{\r\n\s\s\s\s\sset\st\s[clock\sscan\s2000-01-01\s-format\s%Y-%m-%d\s-timezone\s:UTC]\r\n\s\s\s\s\sset\sf\s[clock\sadd\s$t\s1\syear\s-timezone\s:UTC]\r\n\s\s\s\s\sclock\sformat\s$f\s-format\s%Y-%m-%d\s-timezone\s:UTC\r\n\s}\s{2001-01-01}\r\n@@\s-35216,10\s+35220,17\s@@\r\n\s\t\s\s\s\s\s\s\s-timezone\sEST05:00EDT04:00,M4.1.0/02:00,M10.5.0/02:00]\r\n\s\s\s\s\sset\sf1\s[clock\sadd\s$t\s3600\sseconds\s-timezone\sEST05:00EDT04:00,M4.1.0/02:00,M10.5.0/02:00]\r\n\s\s\s\s\sset\sx1\s[clock\sformat\s$f1\s-format\s{%Y-%m-%d\s%H:%M:%S\s%z}\s\\\r\n\s\t\t-timezone\sEST05:00EDT04:00,M4.1.0/02:00,M10.5.0/02:00]\r\n\s}\s{2004-10-31\s01:00:00\s-0500}\r\n+test\sclock-30.26\s{clock\sadd\sweekdays}\s{\r\n+\s\s\s\sset\st\s[clock\sscan\s{2013-11-20}]\s;#\sit's\sa\sWednesday\r\n+\s\s\s\sset\sf1\s[clock\sadd\s$t\s3\sweekdays]\r\n+\s\s\s\sset\sx1\s[clock\sformat\s$f1\s-format\s{%Y-%m-%d}\r\n+}\s{2013-11-6}\r\n+#\sEND\stestcases30\r\n+\r\n\s\r\n\stest\sclock-31.1\s{system\slocale}\s\\\r\n\s\s\s\s\s-constraints\swin\s\\\r\n\s\s\s\s\s-setup\s{\s\r\n\s\tnamespace\seval\s::tcl::clock\s{\r\n\r\n\r\n</verbatim>
J login gahr
J mimetype text/html
K 5f71353740e07843d5f79f60ede92cddc0bb1390
U gahr
Z bf7e40c977465bfe9583af93405410a6