<i>Free-form clock scan silently wraps numbers that do not fit into an int (regression in 9.0)</i> status still Open with 4 other changes
by
.
D 2026-11-14T10:22:35.006
J comment Since\sthe\sclock\srewrite\sin\sTcl\s9.0\s(TIP\s688),\sthe\sfree-form\sparser\sof\s`clock\sscan`\sreads\snumbers\sas\s64-bit\sintegers,\sbut\sstores\sthem\sinto\sthe\s`int`\sfields\sof\sthe\sdate\s(hour,\sminutes,\sday,\smonth,\syear,\sday\sordinal).\sA\snumber\sthat\sdoes\snot\sfit\sinto\san\sint\sis\struncated,\sand\sthe\sresult\sis\soften\sa\svalid\svalue,\sso\sa\swrong\sdate\sis\sreturned\swithout\serror:\r\n\r\n|\sInput\s|\s9.0.5\sand\s9.1.1\s|\s8.6.18\s|\r\n|---|---|---|\r\n|\s`clock\sscan\s12:4294967301:00`\s|\s12:05:00\s|\ssyntax\serror\s|\r\n|\s`clock\sscan\s4294967308:00:00`\s|\s12:00:00\s|\ssyntax\serror\s|\r\n|\s`clock\sscan\s4294967297/02/2026`\s|\s2026-01-02\s|\ssyntax\serror\s|\r\n|\s`clock\sscan\s02/4294967297/2026`\s|\s2026-02-01\s|\ssyntax\serror\s|\r\n|\s`clock\sscan\s02/03/4294969322`\s|\s2026-02-03\s|\ssyntax\serror\s|\r\n|\s`clock\sscan\s"-4294967297\sMonday"`\s|\s1969-12-29\s(a\sMonday)\s|\ssyntax\serror\s|\r\n\r\nWith\sJan's\sfix\sfor\s[8afd93d3d3],\swhich\smakes\s`secondOfMin`\san\sint,\sthe\sseconds\sfield\swould\sbe\saffected\stoo:\s`12:00:4294967301`\swould\sgive\s12:00:05.\r\n\r\nThe\syear\sis\sthe\sonly\sfield\swhose\svalid\srange\s(`-min-year`/`-max-year`)\sis\sthe\swhole\sint\srange\sby\sdefault,\sso\sclamping\salone\scannot\sreject\sit.\r\n\r\nRelative\smonths\sand\syears\sare\swrapped\stoo\s(with\s`-base\s0\s-gmt\s1`):\r\n\r\n|\sInput\s|\s9.0.5\sand\s9.1.1\s|\r\n|---|---|\r\n|\s`clock\sscan\s"4294967297\smonths"`\s|\s1970-02-01\s(1\smonth)\s|\r\n|\s`clock\sscan\s"4294967297\syears"`\s|\s1971-01-01\s(1\syear)\s|\r\n|\s`clock\sscan\s"next\s4294967297\sFeb"`\s|\s1970-02-01\s|\r\n\r\nRelative\sdays,\sweeks,\sfortnights\sand\sseconds\sare\s64-bit\sand\sgive\sthe\sright\sresult.\s8.6.18\sgives\swrong\sresults\sfor\sall\srelative\sunits\swith\sthis\snumber\s(the\syear\s429502\sfor\seach\sof\sthem)\sand\sa\ssyntax\serror\sfor\s`next\s4294967297\sFeb`.
J icomment +1,\sjust\sgo\sahead!
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K f894a85b9a4412d77d4f3234e5a244b7b4d476a2
U jan.nijtmans
Z c913e2de73d8f4cdc821f02d9eaf2922