clock.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
- '"
- '" Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans.
- '" Copyright (c) 1995-1997 Sun Microsystems, Inc.
- '" Copyright (c) 1998-1999 Scriptics Corporation
- '" Copyright (c) 2002 ActiveState Corporation
- '"
- '" This documentation is derived from the time and date facilities of
- '" TclX, by Mark Diekhans and Karl Lehenbauer.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: clock.n,v 1.11.2.6 2004/12/13 15:52:21 kennykb Exp $
- '"
- .so man.macros
- .TH clock n 8.4 Tcl "Tcl Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- clock - Obtain and manipulate time
- .SH SYNOPSIS
- fBclock fIoptionfR ?fIarg arg ...fR?
- .BE
- .SH DESCRIPTION
- .PP
- This command performs one of several operations that may obtain
- or manipulate strings or values that represent some notion of
- time. The fIoptionfR argument determines what action is carried
- out by the command. The legal fIoptionsfR (which may be
- abbreviated) are:
- .VS 8.3
- .TP
- fBclock clicksfR ?fB-millisecondsfR?
- 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. If fB-millisecondsfR 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.
- .VE 8.3
- .TP
- fBclock format fIclockValuefR ?fB-format fIstringfR? ?fB-gmt fIbooleanfR?
- Converts an integer time value, typically returned by
- fBclock secondsfR, fBclock scanfR, or the fBatimefR or fBmtimefR
- options of the fBfilefR command, to human-readable
- form. If the fB-formatfR 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 fB%fR followed by a field
- descriptor character. All other characters are copied into the result.
- Valid field descriptors are:
- .RS
- .IP fB%%fR
- Insert a %.
- .IP fB%afR
- Abbreviated weekday name (Mon, Tue, etc.).
- .IP fB%AfR
- Full weekday name (Monday, Tuesday, etc.).
- .IP fB%bfR
- Abbreviated month name (Jan, Feb, etc.).
- .IP fB%BfR
- Full month name.
- .VS 8.4
- .IP fB%cfR
- Locale specific date and time. The format for date and time
- in the default "C" locale on Unix/Mac is "%a %b %d %H:%M:%S %Y".
- On Windows, this value is the locale specific long date and time, as
- specified in the Regional Options control panel settings.
- .IP fB%CfR
- First two digits of the four-digit year (19 or 20).
- .VE 8.4
- .IP fB%dfR
- Day of month (01 - 31).
- .VS 8.4
- '" Since the inclusion of compat/strftime.c, %D, %e, %h should work on all
- '" platforms.
- .IP fB%DfR
- Date as %m/%d/%y.
- .IP fB%efR
- Day of month (1 - 31), no leading zeros.
- .IP fB%gfR
- The ISO8601 year number corresponding to the ISO8601 week (%V), expressed
- as a two-digit year-of-the-century, with leading zero if necessary.
- .IP fB%GfR
- The ISO8601 year number corresponding to the ISO8601 week (%V), expressed
- as a four-digit number.
- .IP fB%hfR
- Abbreviated month name.
- .VE 8.4
- .IP fB%HfR
- Hour in 24-hour format (00 - 23).
- .VS 8.4
- .IP fB%IfR
- Hour in 12-hour format (01 - 12).
- .VE 8.4
- .IP fB%jfR
- Day of year (001 - 366).
- .VS 8.4
- .IP fB%kfR
- Hour in 24-hour format, without leading zeros (0 - 23).
- .IP fB%lfR
- Hour in 12-hour format, without leading zeros (1 - 12).
- .VE 8.4
- .IP fB%mfR
- Month number (01 - 12).
- .IP fB%MfR
- Minute (00 - 59).
- .VS 8.4
- .IP fB%nfR
- Insert a newline.
- .VE 8.4
- .IP fB%pfR
- AM/PM indicator.
- .VS 8.4
- .IP fB%rfR
- Time in a locale-specific "meridian" format. The "meridian"
- format in the default "C" locale is "%I:%M:%S %p".
- .IP fB%RfR
- Time as %H:%M.
- .IP fB%sfR
- Count of seconds since the epoch, expressed as a decimal integer.
- .VE 8.4
- .IP fB%SfR
- Seconds (00 - 59).
- .VS 8.4
- .IP fB%tfR
- Insert a tab.
- .IP fB%TfR
- Time as %H:%M:%S.
- .IP fB%ufR
- Weekday number (Monday = 1, Sunday = 7).
- .VE 8.4
- .IP fB%UfR
- Week of year (00 - 52), Sunday is the first day of the week.
- .VS 8.4
- .IP fB%VfR
- Week of year according to ISO-8601 rules. Week 1 of a given
- year is the week containing 4 January.
- .IP fB%wfR
- Weekday number (Sunday = 0, Saturday = 6).
- .VE 8.4
- .IP fB%WfR
- Week of year (00 - 52), Monday is the first day of the week.
- .VS 8.4
- .IP fB%xfR
- Locale specific date format. The format for a date in the default "C"
- locale for Unix/Mac is "%m/%d/%y".
- On Windows, this value is the locale specific short date format, as
- specified in the Regional Options control panel settings.
- .IP fB%XfR
- Locale specific 24-hour time format. The format for a
- 24-hour time in the default "C" locale for Unix/Mac is "%H:%M:%S".
- On Windows, this value is the locale specific time format, as
- specified in the Regional Options control panel settings.
- .VE 8.4
- .IP fB%yfR
- Year without century (00 - 99).
- .IP fB%YfR
- Year with century (e.g. 1990)
- .IP fB%ZfR
- Time zone name.
- .RE
- .VS 8.4
- .sp
- '" All the field descriptors should be portable now that
- '" compat/strftime.c is in place, with the possible exception
- '" of the time zone name.
- '".RS
- '"In addition, the following field descriptors may be supported on some
- '"systems (e.g. Unix but not Windows):
- '".IP fB%DfR
- '"Date as %m/%d/%y.
- '".IP fB%efR
- '"Day of month (1 - 31), no leading zeros.
- '".IP fB%hfR
- '"Abbreviated month name.
- '".IP fB%nfR
- '"Insert a newline.
- '".IP fB%rfR
- '"Time as %I:%M:%S %p.
- '".IP fB%RfR
- '"Time as %H:%M.
- '".IP fB%tfR
- '"Insert a tab.
- '".IP fB%TfR
- '"Time as %H:%M:%S.
- '".RE
- '".sp
- .VE 8.4
- .RS
- If the fB-formatfR argument is not specified, the format string
- fB"%a %b %d %H:%M:%S %Z %Y"fR is used. If the fB-gmtfR argument
- is present the next argument must be a boolean 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.
- .RE
- .TP
- fBclock scan fIdateStringfR ?fB-base fIclockValfR? ?fB-gmt fIbooleanfR?
- Convert fIdateStringfR to an integer clock value (see fBclock secondsfR).
- 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
- specified, the current date is assumed. If the string does not contain a
- time zone mnemonic, the local time zone is assumed, unless the fB-gmtfR
- argument is true, in which case the clock value is calculated assuming
- that the specified time is relative to Greenwich Mean Time.
- fB-gmtfR, if specified, affects only the computed time value; it does not
- impact the interpretation of fB-basefR.
- .sp
- If the fB-basefR 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.
- .sp
- The fIdateStringfR consists of zero or more specifications of the
- following form:
- .RS
- .TP
- fItimefR
- A time of day, which is of the form: fIhhfR?fI:mmfR?fI:ssfR??
- ?fImeridianfR? ?fIzonefR? or fIhhmm fR?fImeridianfR?
- ?fIzonefR?. If no meridian is specified, fIhhfR is interpreted on
- a 24-hour clock.
- .TP
- fIdatefR
- A specific month and day with optional year. The
- acceptable formats are fImm/ddfR?fI/yyfR?, fImonthname ddfR
- ?, fIyyfR?, fIdd monthname fR?fIyyfR?, fIday, dd monthname
- yyfR, fI?CC?yymmddfR, fI?CC?yy-mm-ddfR, fIdd-monthname-?CC?yyfR.
- The default year is the current year. If the year is less
- .VS
- 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 may result if these years are used.
- .VE
- .TP
- fIISO 8601 point-in-timefR
- An ISO 8601 point-in-time specification, such as fICCyymmddThhmmssfR, where
- T is the literal T, fICCyymmdd hhmmssfR, or
- fICCyymmddThh:mm:ssfR. Note that only these three formats are accepted.
- The command does fInotfR accept the full range of point-in-time
- specifications specified in ISO8601. Other formats can be recognized by
- using commands such as fBregexpfR to extract their fields and reorganize
- them into a form accepted by the fBclock scanfR command.
- .TP
- fIrelative timefR
- A specification relative to the current time. The format is fInumber
- unitfR acceptable units are fByearfR, fBfortnightfR, fBmonthfR, fBweekfR, fBdayfR,
- fBhourfR, fBminutefR (or fBminfR), and fBsecondfR (or fBsecfR). The
- unit can be specified as a singular or plural, as in fB3 weeksfR.
- These modifiers may also be specified:
- fBtomorrowfR, fByesterdayfR, fBtodayfR, fBnowfR,
- fBlastfR, fBthisfR, fBnextfR, fBagofR.
- .RE
- .sp
- .RS
- The actual date is calculated according to the following 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
- specified, and no absolute or relative time 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
- differences and the correct date is given when going from the end
- of a long month to a short month.
- .sp
- Daylight savings time correction is applied only when the relative time
- is specified in units of days or more, ie, days, weeks, fortnights, months or
- years. This means that when crossing the daylight savings time boundary,
- different results will be given for fBclock scan "1 day"fR and
- fBclock scan "24 hours"fR:
- .CS
- .ta 6c
- % fBclock scanfR "1 day" -base [fBclock scanfR 1999-10-31]
- 941443200
- % fBclock scanfR "24 hours" -base [fBclock scanfR 1999-10-31]
- 941439600
- .CE
- .RE
- .TP
- fBclock secondsfR
- 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.
- .SH "SEE ALSO"
- date(1), time(n)
- .SH KEYWORDS
- clock, date, time