Part of the [clock] command. See http://purl.org/tcl/home/man/tcl8.5/TclCmd/clock.htm for the formal man page. : '''clock scan''' ''inputString'' ?''-option value...''? Parses the time described in ''inputString'' and returns the number of seconds (since the start of the Unix epoch) that that time corresponds to. Supported ''-option''s are: : '''-base''' ''time'' : '''-format''' ''format'' : '''-gmt''' ''boolean'' : '''-locale''' ''localeName'' : '''-timezone''' ''zoneName'' <> [JMN] 2007-11-14 On FreeBSD - you can configure the timezone to UTC by removing `/etc/localtime`. I don't know if this is actually a legitimate way to set it to UTC, but it was the only way I knew of until now, and it does seem to cause a problem with Tcl's clock scan. ====== % clock scan "2007-11-01" -format "%Y-%m-%d" time value too large/small to represent % clock scan "2007-11-01" -format "%Y-%m-%d" 1193875200 ====== The call always fails the first time in each process, and seems to work for all calls thereafter. (including in other interps) If you configure the timezone to UTC by instead making `/etc/localtime` a link to `/usr/share/zoneinfo/Etc/UTC` the problem doesn't occur. I have a number of systems configured with no `/etc/localtime` - but I guess I'll change that now in light of this. This issue also shows up in the FAQ on http://amsn-project.net/ . Is a missing `/etc/localtime` something that clock scan should be able to handle - or is it would it be considered an OS configuration issue? [DKF]: Ultimately, I'd consider this to be OS misconfiguration as it feels like stating that the system has ''no'' local timezone instead of that it is UTC. ---- [sbron] 2009-06-14 - Since Tcl 8.5, clock scan is very relaxed about the dates it accepts (it sees no problem in "March 0" or "April 34"), so it can no longer be used directly for validation. That's why I wrote my own [Time and date validator]. [RLH] I am sure there was '''a''' reason that clock will accept invalid dates. I cannot for the life of me think of one though. [Mat] Since this might break a lot of existing code, I hope that reason was a good one.. ;) [LV] I wonder why this problem now exists. ---- [TCV] (2013-02-11) Note that providing only a year (e.g. `%Y`) in the format string will ''not'' produce the time for the first day of that year. Similarly, providing only the year and month (e.g. `%m/%Y`) in the format string will ''not'' produce the time for the first day of that month. In both of these cases, you will instead get the time corresponding to midnight on the current day. Currently in `clock scan`, to avoid this behaviour, day level accuracy is required; this can be done by specifying: * year and day-of-year * week and day-of-week * month and day-of-month So in the examples above, just adding to the input string `01` for each of the missing fields will give you the time you're interested in (first day of the year or month, respectively). Examples: ====== # Things you might think would behave differently. % clock scan "2000" -format "%Y" 1360558800 % clock scan "01/2000" -format "%m/%Y" 1360558800 # They're actually midnight today! % clock format [clock seconds] -format "%Y-%m-%d" 2013-02-11 % clock scan [clock format [clock seconds] -format "%Y-%m-%d"] 1360558800 # A simple solution. That's what I really meant! % clock scan "2000-01-01" -format "%Y-%m-%d" 946702800 ====== <> Command | Date and Time