clock(3,n)(n) Tcl Built-In Commands clock(3,n)(n) NAME clock(3,n) - Obtain and manipulate time(1,2,n) SYNOPSIS clock(3,n) option ?arg arg ...? DESCRIPTION This command performs one of several operations that may obtain or manipulate strings or values that represent some notion of time. The option argument determines what action is carried out by the command. The legal options (which may be abbreviated) are: clock(3,n) clicks ?-milliseconds? Return a high-resolution time(1,2,n) value as a system-dependent inte- ger value. The unit of the value is system-dependent but should be the highest resolution clock(3,n) available on the system such as a CPU cycle counter. If -milliseconds is specified, then the value is guaranteed to be of millisecond granularity. This value should only be used for the relative measurement of elapsed time. clock(3,n) format clockValue ?-format string(3,n)? ?-gmt boolean? Converts an integer time(1,2,n) value, typically returned by clock(3,n) sec- onds, clock(3,n) scan, or the atime, mtime, or ctime options of the file(1,n) command, to human-readable form. If the -format argument is present the next argument is a string(3,n) that describes how the date and time(1,2,n) are to be formatted. Field descriptors consist of a % followed by a field descriptor character. All other charac- ters are copied into the result. Valid field descriptors are: %% Insert a %. %a Abbreviated weekday name (Mon, Tue, etc.). %A Full weekday name (Monday, Tuesday, etc.). %b Abbreviated month name (Jan, Feb, etc.). %B Full month name. %c Locale specific date and time. The format for date and time(1,2,n) in(1,8) the default "C" locale(3,5,7) on Unix/Mac is "%a %b %d %H:%M:%S %Y". On Windows, this value is the locale(3,5,7) spe- cific long date and time(1,2,n), as specified in(1,8) the Regional Options control panel(1,3x,3x bottom_panel) settings. %C First two digits of the four-digit year (19 or 20). %d Day of month (01 - 31). %D Date as %m/%d/%y. %e Day of month (1 - 31), no leading zeros. %h Abbreviated month name. %H Hour in(1,8) 24-hour format (00 - 23). %I Hour in(1,8) 12-hour format (01 - 12). %j Day of year (001 - 366). %k Hour in(1,8) 24-hour format, without leading zeros (0 - 23). %l Hour in(1,8) 12-hour format, without leading zeros (1 - 12). %m Month number (01 - 12). %M Minute (00 - 59). %n Insert a newline. %p AM/PM indicator. %r Time in(1,8) a locale-specific "meridian" format. The "merid- ian" format in(1,8) the default "C" locale(3,5,7) is "%I:%M:%S %p". %R Time as %H:%M. %s Count of seconds since the epoch, expressed as a decimal integer. %S Seconds (00 - 59). %t Insert a tab. %T Time as %H:%M:%S. %u Weekday number (Monday = 1, Sunday = 7). %U Week of year (00 - 52), Sunday is the first day of the week. %V Week of year according to ISO-8601 rules. Week 1 of a given year is the week containing 4 January. %w Weekday number (Sunday = 0, Saturday = 6). %W Week of year (00 - 52), Monday is the first day of the week. %x Locale specific date format. The format for a date in(1,8) the default "C" locale(3,5,7) for Unix/Mac is "%m/%d/%y". On Windows, this value is the locale(3,5,7) specific short date format, as specified in(1,8) the Regional Options control panel(1,3x,3x bottom_panel) settings. %X Locale specific 24-hour time(1,2,n) format. The format for a 24-hour time(1,2,n) in(1,8) the default "C" locale(3,5,7) for Unix/Mac is "%H:%M:%S". On Windows, this value is the locale(3,5,7) spe- cific time(1,2,n) format, as specified in(1,8) the Regional Options control panel(1,3x,3x bottom_panel) settings. %y Year without century (00 - 99). %Y Year with century (e.g. 1990) %Z Time zone name. If the -format argument is not specified, the format string(3,n) "%a %b %d %H:%M:%S %Z %Y" is used. If the -gmt argument is present the next argument must be a boolean which if(3,n) true specifies that the time(1,2,n) will be formatted as Greenwich Mean Time. If false then the local timezone will be used as defined by the operating environment. clock(3,n) scan dateString ?-base clockVal? ?-gmt boolean? Convert dateString to an integer clock(3,n) value (see clock(3,n) sec- onds). This command can parse and convert virtually any stan- dard date and/or time(1,2,n) string(3,n), which can include standard time(1,2,n) zone mnemonics. If only a time(1,2,n) is specified, the current date is assumed. If the string(3,n) does not contain a time(1,2,n) zone mnemonic, the local time(1,2,n) zone is assumed, unless the -gmt argu- ment is true, in(1,8) which case the clock(3,n) value is calculated assum- ing that the specified time(1,2,n) is relative to Greenwich Mean Time. -gmt, if(3,n) specified, affects only the computed time(1,2,n) value; it does not impact the interpretation of -base. If the -base flag is specified, the next argument should contain an integer clock(3,n) value. Only the date in(1,8) this value is used, not the time. This is useful for determining the time(1,2,n) on a spe- cific day or doing other date-relative conversions. The dateString consists of zero or more specifications of the following form: time(1,2,n) A time(1,2,n) of day, which is of the form: hh?:mm?:ss?? ?meridian? ?zone? or hhmm ?meridian? ?zone?. If no meridian is specified, hh is interpreted on a 24-hour clock. date A specific month and day with optional year. The accept- able formats are mm/dd?/yy?, monthname dd ?, yy?, dd mon- thname ?yy?, day, dd monthname yy, ?CC?yymmdd, ?CC?yy-mm- dd, dd-monthname-?CC?yy. The default year is the current year. If the year is less(1,3) than 100, we treat the years 00-68 as 2000-2068 and the years 69-99 as 1969-1999. Not all platforms can represent the years 38-70, so an error(8,n) may result if(3,n) these years are used. ISO 8601 point-in-time An ISO 8601 point-in-time specification, such as CCyymmd- dThhmmss, where T is the literal T, CCyymmdd hhmmss, or CCyymmddThh:mm:ss. relative time(1,2,n) A specification relative to the current time. The format is number unit acceptable units(1,7) are year, fortnight, month, week, day, hour, minute (or min), and second (or sec). The unit can be specified as a singular or plural, as in(1,8) 3 weeks. These modifiers may also be specified: tomorrow, yesterday, today, now, last, this, next, ago. The actual date is calculated according to the following steps. First, any absolute date and/or time(1,2,n) is processed and converted. Using that time(1,2,n) as the base, day-of-week specifications are added. Next, relative specifications are used. If a date or day is specified, and no absolute or relative time(1,2,n) is given, midnight is used. Finally, a correction is applied so that the correct hour of the day is produced after allowing for daylight savings time(1,2,n) differences and the correct date is given when going from the end of a long month to a short month. Daylight savings time(1,2,n) correction is applied only when the rela- tive time(1,2,n) is specified in(1,8) units(1,7) of days or more, ie, days, weeks, fortnights, months or years. This means that when cross- ing the daylight savings time(1,2,n) boundary, different results will be given for clock(3,n) scan "1 day" and clock(3,n) scan "24 hours": % clock(3,n) scan "1 day" -base [clock(3,n) scan 1999-10-31] 941443200 % clock(3,n) scan "24 hours" -base [clock(3,n) scan 1999-10-31] 941439600 clock(3,n) seconds Return the current date and time(1,2,n) as a system-dependent integer value. The unit of the value is seconds, allowing it to be used for relative time(1,2,n) calculations. The value is usually defined as total elapsed time(1,2,n) from an ``epoch''. You shouldn't assume the value of the epoch. SEE ALSO date(1), time(1,2,n)(n) KEYWORDS clock(3,n), date, time(1,2,n) Tcl 8.4 clock(3,n)(n)