clock(n) Tcl Built-In Commands clock(n) _________________________________________________________________ NAME clock - Obtain and manipulate time SYNOPSIS clock _o_p_t_i_o_n ?_a_r_g _a_r_g ...? _________________________________________________________________ DESCRIPTION This command performs one of several operations that may obtain or manipulate strings or values that represent some notion of time. The _o_p_t_i_o_n argument determines what action is carried out by the command. The legal _o_p_t_i_o_n_s (which may be abbreviated) are: clock clicks Return a high-resolution time value as a system- dependent integer value. The unit of the value is system-dependent but should be the highest resolution clock available on the system such as a CPU cycle counter. This value should only be used for the rela- tive measurement of elapsed time. clock format _c_l_o_c_k_V_a_l_u_e ?-format _s_t_r_i_n_g? ?-gmt _b_o_o_l_e_a_n? Converts an integer time value, typically returned by clock seconds, clock scan, or the atime, mtime, or ctime options of the file command, to human-readable form. If the - format argument is present the next argument is a string that describes how the date and time are to be formatted. Field descriptors consist of a % followed by a field descriptor character. All other characters 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. %d Day of month (01 - 31). %H Hour in 24-hour format (00 - 23). Tcl Last change: 7.4 1 clock(n) Tcl Built-In Commands clock(n) %I Hour in 12-hour format (00 - 12). %j Day of year (001 - 366). %m Month number (01 - 12). %M Minute (00 - 59). %p AM/PM indicator. %S Seconds (00 - 59). %U Week of year (01 - 52), Sunday is the first day of the week. %w Weekday number (Sunday = 0). %W Week of year (01 - 52), Monday is the first day of the week. %x Locale specific date format. %X Locale specific time format. %y Year without century (00 - 99). %Y Year with century (e.g. 1990) %Z Time zone name. In addition, the following field descriptors may be supported on some systems (e.g. Unix but not Windows): %D Date as %m/%d/%y. %e Day of month (1 - 31), no leading zeros. %h Abbreviated month name. %n Insert a newline. %r Time as %I:%M:%S %p. %R Time as %H:%M. %t Insert a tab. %T Time as %H:%M:%S. If the -format argument is not specified, the format string "%a %b %d %H:%M:%S %Z %Y" is used. If the -gmt argument is present the next argument must be a boolean Tcl Last change: 7.4 2 clock(n) Tcl Built-In Commands clock(n) which if true specifies that the time will be formatted as Greenwich Mean Time. If false then the local timezone will be used as defined by the operating environment. clock scan _d_a_t_e_S_t_r_i_n_g ?-base _c_l_o_c_k_V_a_l? ?-gmt _b_o_o_l_e_a_n? Convert _d_a_t_e_S_t_r_i_n_g to an integer clock value (see clock seconds). This command can parse and convert virtually any standard date and/or time string, which can include standard time zone mnemonics. If only a time is speci- fied, the current date is assumed. If the string does not contain a time zone mnemonic, the local time zone is assumed, unless the -gmt argument is true, in which case the clock value is calculated assuming that the specified time is relative to Greenwich Mean Time. If the -base flag is specified, the next argument should contain an integer clock value. Only the date in this value is used, not the time. This is useful for determining the time on a specific day or doing other date-relative conversions. The _d_a_t_e_S_t_r_i_n_g consists of zero or more specifications of the following form: _t_i_m_e A time of day, which is of the form: _h_h?:_m_m?:_s_s?? ?_m_e_r_i_d_i_a_n? ?_z_o_n_e? or _h_h_m_m ?_m_e_r_i_d_i_a_n? ?_z_o_n_e?. If no meridian is specified, _h_h is interpreted on a 24- hour clock. _d_a_t_e A specific month and day with optional year. The acceptable formats are _m_m/_d_d?/_y_y?, _m_o_n_t_h_n_a_m_e _d_d ?, _y_y?, _d_d _m_o_n_t_h_n_a_m_e ?_y_y? and _d_a_y, _d_d _m_o_n_t_h_n_a_m_e _y_y. The default year is the current year. If the year is less then 100, then 1900 is added to it. _r_e_l_a_t_i_v_e _t_i_m_e A specification relative to the current time. The format is _n_u_m_b_e_r _u_n_i_t acceptable units are year, fortnight, month, week, day, hour, minute (or min), and second (or sec). The unit can be speci- fied as a singular or plural, as in 3 weeks. These modifiers may also be specified: tomorrow, yesterday, today, now, last, this, next, ago. The actual date is calculated according to the follow- ing steps. First, any absolute date and/or time is processed and converted. Using that time as the base, day-of-week specifications are added. Next, relative specifications are used. If a date or day is speci- fied, and no absolute or relative time is given, mid- night is used. Finally, a correction is applied so Tcl Last change: 7.4 3 clock(n) Tcl Built-In Commands clock(n) that the correct hour of the day is produced after allowing for daylight savings time differences. clock seconds Return the current date and time as a system-dependent integer value. The unit of the value is seconds, allowing it to be used for relative time calculations. The value is usually defined as total elapsed time from an ``epoch''. You shouldn't assume the value of the epoch. KEYWORDS clock, date, time Tcl Last change: 7.4 4