1clock(n)                     Tcl Built-In Commands                    clock(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       clock - Obtain and manipulate time
9

SYNOPSIS

11       clock option ?arg arg ...?
12_________________________________________________________________
13
14

DESCRIPTION

16       This  command  performs  one  of  several operations that may obtain or
17       manipulate strings or values that represent some notion of  time.   The
18       option  argument  determines what action is carried out by the command.
19       The legal options (which may be abbreviated) are:                       │
20
21       clock clicks ?-milliseconds?                                            │
22              Return a high-resolution time value as a system-dependent  inte‐ │
23              ger value.  The unit of the value is system-dependent but should │
24              be the highest resolution clock available on the system such  as │
25              a  CPU  cycle  counter.  If -milliseconds is specified, then the │
26              value is guaranteed to  be  of  millisecond  granularity.   This │
27              value  should  only  be  used  for  the  relative measurement of │
28              elapsed time.
29
30       clock format clockValue ?-format string? ?-gmt boolean?
31              Converts an integer time value, typically returned by clock sec‐
32              onds, clock scan, or the atime or mtime options of the file com‐
33              mand, to  human-readable  form.   If  the  -format  argument  is
34              present  the  next  argument  is a string that describes how the
35              date and time are to be formatted.  Field descriptors consist of
36              a % followed by a field descriptor character.  All other charac‐
37              ters are copied into the result.  Valid field descriptors are:
38
39              %%     Insert a %.
40
41              %a     Abbreviated weekday name (Mon, Tue, etc.).
42
43              %A     Full weekday name (Monday, Tuesday, etc.).
44
45              %b     Abbreviated month name (Jan, Feb, etc.).
46
47              %B     Full month name.                                          │
48
49              %c                                                               
50                     Locale specific date and time.  The format for  date  and │
51                     time  in  the default "C" locale on Unix/Mac is "%a %b %d │
52                     %H:%M:%S %Y".  On Windows, this value is the locale  spe‐ │
53                     cific  long  date  and time, as specified in the Regional │
54                     Options control panel settings.                           │
55
56              %C                                                               
57                     First two digits of the four-digit year (19 or 20).
58
59              %d     Day of month (01 - 31).                                   │
60
61              %D                                                               
62                     Date as %m/%d/%y.                                         │
63
64              %e                                                               
65                     Day of month (1 - 31), no leading zeros.                  │
66
67              %g                                                               
68                     The ISO8601 year number corresponding to the ISO8601 week │
69                     (%V),  expressed as a two-digit year-of-the-century, with │
70                     leading zero if necessary.                                │
71
72              %G                                                               
73                     The ISO8601 year number corresponding to the ISO8601 week │
74                     (%V), expressed as a four-digit number.                   │
75
76              %h                                                               
77                     Abbreviated month name.
78
79              %H     Hour in 24-hour format (00 - 23).                         │
80
81              %I                                                               
82                     Hour in 12-hour format (01 - 12).
83
84              %j     Day of year (001 - 366).                                  │
85
86              %k                                                               
87                     Hour in 24-hour format, without leading zeros (0 - 23).   │
88
89              %l                                                               
90                     Hour in 12-hour format, without leading zeros (1 - 12).
91
92              %m     Month number (01 - 12).
93
94              %M     Minute (00 - 59).                                         │
95
96              %n                                                               
97                     Insert a newline.
98
99              %p     AM/PM indicator.                                          │
100
101              %r                                                               
102                     Time in a locale-specific "meridian" format.  The "merid‐ │
103                     ian" format in the default "C" locale is "%I:%M:%S %p".   │
104
105              %R                                                               
106                     Time as %H:%M.                                            │
107
108              %s                                                               
109                     Count of seconds since the epoch, expressed as a  decimal │
110                     integer.
111
112              %S     Seconds (00 - 59).                                        │
113
114              %t                                                               
115                     Insert a tab.                                             │
116
117              %T                                                               
118                     Time as %H:%M:%S.                                         │
119
120              %u                                                               
121                     Weekday number (Monday = 1, Sunday = 7).
122
123              %U     Week  of  year  (00 - 52), Sunday is the first day of the
124                     week.                                                     │
125
126              %V                                                               
127                     Week of year according to ISO-8601 rules.  Week  1  of  a │
128                     given year is the week containing 4 January.              │
129
130              %w                                                               
131                     Weekday number (Sunday = 0, Saturday = 6).
132
133              %W     Week  of  year  (00 - 52), Monday is the first day of the
134                     week.                                                     │
135
136              %x                                                               
137                     Locale specific date format.  The format for  a  date  in │
138                     the  default  "C"  locale for Unix/Mac is "%m/%d/%y".  On │
139                     Windows, this value is the  locale  specific  short  date │
140                     format,  as  specified  in  the  Regional Options control │
141                     panel settings.                                           │
142
143              %X                                                               
144                     Locale specific 24-hour time format.  The  format  for  a │
145                     24-hour  time  in  the default "C" locale for Unix/Mac is │
146                     "%H:%M:%S".  On Windows, this value is  the  locale  spe‐ │
147                     cific  time  format, as specified in the Regional Options │
148                     control panel settings.
149
150              %y     Year without century (00 - 99).
151
152              %Y     Year with century (e.g. 1990)
153
154              %Z     Time zone name.
155
156              If the -format argument is not specified, the format string  "%a 
157              %b  %d %H:%M:%S %Z %Y" is used.  If the -gmt argument is present
158              the next argument must be a boolean which if true specifies that
159              the time will be formatted as Greenwich Mean Time. If false then
160              the local timezone will be used  as  defined  by  the  operating
161              environment.
162
163       clock scan dateString ?-base clockVal? ?-gmt boolean?
164              Convert  dateString  to  an  integer clock value (see clock sec‐
165              onds).  This command can parse and convert virtually  any  stan‐
166              dard  date  and/or  time string, which can include standard time
167              zone mnemonics.  If only a time is specified, the  current  date
168              is  assumed.   If  the  string  does  not  contain  a  time zone
169              mnemonic, the local time zone is assumed, unless the -gmt  argu‐
170              ment is true, in which case the clock value is calculated assum‐
171              ing that the specified time is relative to Greenwich Mean  Time.
172              -gmt,  if  specified,  affects  only the computed time value; it
173              does not impact the interpretation of -base.
174
175              If the -base flag is specified, the next argument should contain
176              an  integer  clock  value.  Only the date in this value is used,
177              not the time.  This is useful for determining the time on a spe‐
178              cific day or doing other date-relative conversions.
179
180              The  dateString  consists  of zero or more specifications of the
181              following form:
182
183              time   A time  of  day,  which  is  of  the  form:  hh?:mm?:ss??
184                     ?meridian?  ?zone?  or  hhmm  ?meridian?   ?zone?.  If no
185                     meridian is specified, hh is  interpreted  on  a  24-hour
186                     clock.
187
188              date   A specific month and day with optional year.  The accept‐
189                     able formats are mm/dd?/yy?, monthname dd ?, yy?, dd mon‐
190                     thname ?yy?, day, dd monthname yy, ?CC?yymmdd, ?CC?yy-mm-
191                     dd, dd-monthname-?CC?yy.  The default year is the current
192                     year.   If  the year is less than 100, we treat the years │
193                     00-68 as 2000-2068 and the years 69-99 as 1969-1999.  Not │
194                     all  platforms can represent the years 38-70, so an error │
195                     may result if these years are used.
196
197              ISO 8601 point-in-time
198                     An ISO 8601 point-in-time specification, such as CCyymmd‐
199                     dThhmmss,  where  T is the literal T, CCyymmdd hhmmss, or
200                     CCyymmddThh:mm:ss.  Note that only  these  three  formats
201                     are accepted.  The command does not accept the full range
202                     of point-in-time  specifications  specified  in  ISO8601.
203                     Other formats can be recognized by using commands such as
204                     regexp to extract their fields and reorganize them into a
205                     form accepted by the clock scan command.
206
207              relative time
208                     A specification relative to the current time.  The format
209                     is number unit  acceptable  units  are  year,  fortnight,
210                     month,  week,  day, hour, minute (or min), and second (or
211                     sec).  The unit can be specified as a singular or plural,
212                     as  in  3  weeks.  These modifiers may also be specified:
213                     tomorrow, yesterday, today, now, last, this, next, ago.
214
215              The actual date is calculated according to the following  steps.
216              First, any absolute date and/or time is processed and converted.
217              Using that time as  the  base,  day-of-week  specifications  are
218              added.   Next,  relative  specifications are used.  If a date or
219              day is specified, and no absolute or  relative  time  is  given,
220              midnight  is used.  Finally, a correction is applied so that the
221              correct hour of the day is produced after allowing for  daylight
222              savings  time  differences  and  the  correct date is given when
223              going from the end of a long month to a short month.
224
225              Daylight savings time correction is applied only when the  rela‐
226              tive  time  is  specified  in  units  of days or more, ie, days,
227              weeks, fortnights, months or years.  This means that when cross‐
228              ing  the  daylight savings time boundary, different results will
229              be given for clock scan "1 day" and clock scan "24 hours":
230                     % clock scan "1 day" -base [clock scan 1999-10-31]
231                     941443200
232                     % clock scan "24 hours" -base [clock scan 1999-10-31]
233                     941439600
234
235       clock seconds
236              Return the current date and time as a  system-dependent  integer
237              value.  The unit of the value is seconds, allowing it to be used
238              for relative time calculations.  The value is usually defined as
239              total  elapsed time from an ``epoch''.  You shouldn't assume the
240              value of the epoch.
241
242

SEE ALSO

244       date(1), time(n)
245
246

KEYWORDS

248       clock, date, time
249
250
251
252Tcl                                   8.4                             clock(n)
Impressum