'\" '\" Copyright (c) 1992-1995 Karl Lehenbauer and Mark Diekhans. '\" Copyright (c) 1995-1997 Sun Microsystems, Inc. '\" Copyright (c) 1998-1999 Scriptics 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.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" The definitions below are for supplemental macros used in Tcl/Tk '\" manual entries. '\" '\" .AP type name in/out ?indent? '\" Start paragraph describing an argument to a library procedure. '\" type is type of argument (int, etc.), in/out is either "in", "out", '\" or "in/out" to describe whether procedure reads or modifies arg, '\" and indent is equivalent to second arg of .IP (shouldn't ever be '\" needed; use .AS below instead) '\" '\" .AS ?type? ?name? '\" Give maximum sizes of arguments for setting tab stops. Type and '\" name are examples of largest possible arguments that will be passed '\" to .AP later. If args are omitted, default tab stops are used. '\" '\" .BS '\" Start box enclosure. From here until next .BE, everything will be '\" enclosed in one large box. '\" '\" .BE '\" End of box enclosure. '\" '\" .CS '\" Begin code excerpt. '\" '\" .CE '\" End code excerpt. '\" '\" .VS ?version? ?br? '\" Begin vertical sidebar, for use in marking newly-changed parts '\" of man pages. The first argument is ignored and used for recording '\" the version when the .VS was added, so that the sidebars can be '\" found and removed when they reach a certain age. If another argument '\" is present, then a line break is forced before starting the sidebar. '\" '\" .VE '\" End of vertical sidebar. '\" '\" .DS '\" Begin an indented unfilled display. '\" '\" .DE '\" End of indented unfilled display. '\" '\" .SO '\" Start of list of standard options for a Tk widget. The '\" options follow on successive lines, in four columns separated '\" by tabs. '\" '\" .SE '\" End of list of standard options for a Tk widget. '\" '\" .OP cmdName dbName dbClass '\" Start of description of a specific option. cmdName gives the '\" option's name as specified in the class command, dbName gives '\" the option's name in the option database, and dbClass gives '\" the option's class in the option database. '\" '\" .UL arg1 arg2 '\" Print arg1 underlined, then print arg2 normally. '\" '\" RCS: @(#) $Id: clock.n,v 1.2 2003/11/24 05:09:59 bbbush Exp $ '\" '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. .if t .wh -1.3i ^B .nr ^l \n(.l .ad b '\" # Start an argument description .de AP .ie !"\\$4"" .TP \\$4 .el \{\ . ie !"\\$2"" .TP \\n()Cu . el .TP 15 .\} .ta \\n()Au \\n()Bu .ie !"\\$3"" \{\ \&\\$1 \\fI\\$2\\fP (\\$3) .\".b .\} .el \{\ .br .ie !"\\$2"" \{\ \&\\$1 \\fI\\$2\\fP .\} .el \{\ \&\\fI\\$1\\fP .\} .\} .. '\" # define tabbing values for .AP .de AS .nr )A 10n .if !"\\$1"" .nr )A \\w'\\$1'u+3n .nr )B \\n()Au+15n .\" .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n .nr )C \\n()Bu+\\w'(in/out)'u+2n .. .AS Tcl_Interp Tcl_CreateInterp in/out '\" # BS - start boxed text '\" # ^y = starting y location '\" # ^b = 1 .de BS .br .mk ^y .nr ^b 1u .if n .nf .if n .ti 0 .if n \l'\\n(.lu\(ul' .if n .fi .. '\" # BE - end boxed text (draw box now) .de BE .nf .ti 0 .mk ^t .ie n \l'\\n(^lu\(ul' .el \{\ .\" Draw four-sided box normally, but don't draw top of .\" box if the box started on an earlier page. .ie !\\n(^b-1 \{\ \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .el \}\ \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' .\} .\} .fi .br .nr ^b 0 .. '\" # VS - start vertical sidebar '\" # ^Y = starting y location '\" # ^v = 1 (for troff; for nroff this doesn't matter) .de VS .if !"\\$2"" .br .mk ^Y .ie n 'mc \s12\(br\s0 .el .nr ^v 1u .. '\" # VE - end of vertical sidebar .de VE .ie n 'mc .el \{\ .ev 2 .nf .ti 0 .mk ^t \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' .sp -1 .fi .ev .\} .nr ^v 0 .. '\" # Special macro to handle page bottom: finish off current '\" # box/sidebar if in box/sidebar mode, then invoked standard '\" # page bottom macro. .de ^B .ev 2 'ti 0 'nf .mk ^t .if \\n(^b \{\ .\" Draw three-sided box if this is the box's first page, .\" draw two sides but no top otherwise. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c .\} .if \\n(^v \{\ .nr ^x \\n(^tu+1v-\\n(^Yu \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c .\} .bp 'fi .ev .if \\n(^b \{\ .mk ^y .nr ^b 2 .\} .if \\n(^v \{\ .mk ^Y .\} .. '\" # DS - begin display .de DS .RS .nf .sp .. '\" # DE - end display .de DE .fi .RE .sp .. '\" # SO - start of list of standard options .de SO .SH "STANDARD OPTIONS" .LP .nf .ta 5.5c 11c .ft B .. '\" # SE - end of list of standard options .de SE .fi .ft R .LP See the \\fBoptions\\fR manual entry for details on the standard options. .. '\" # OP - start of full description for a single option .de OP .LP .nf .ta 4c Command-Line Name: \\fB\\$1\\fR Database Name: \\fB\\$2\\fR Database Class: \\fB\\$3\\fR .fi .IP .. '\" # CS - begin code excerpt .de CS .RS .nf .ta .25i .5i .75i 1i .. '\" # CE - end code excerpt .de CE .fi .RE .. .de UL \\$1\l'|0\(ul'\\$2 .. .TH clock 3tcl 8.3 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME clock \- 獲取和操縱時間 .SH "總覽 SYNOPSIS" \fBclock \fIoption\fR ?\fIarg arg ...\fR? .BE .SH "描述 DESCRIPTION" .PP 這個命令進行多種操作中的某一個,可以獲取或操縱表示一些時間概念(notion)的字符串或值。\fIoption\fR 參數確定這個命令完成什麼操作。合法的 \fIoptions\fR (可以使用縮寫) 有: .TP .VS 8.3 \fBclock clicks\fR ?\fB\-milliseconds\fR? 返回一個高解析度(high-resolution)的時間值,是一個依賴於系統的整數。值的單位是依賴於系統的但應該是系統上可獲得的最高解析度的時鐘,比如一個 CPU 週期記數(counter)。如果指定了 \fB-milliseconds\fR ,則保證這個值是微秒的粒度。這個值只應用於流逝了的時間的相對測量。 .VE 8.3 .TP \fBclock format \fIclockValue\fR ?\fB\-format \fIstring\fR? ?\fB\-gmt \fIboolean\fR? 把一個整數時間值轉換成人可閱讀的形式,典型的,這個時間值是從 \fBclock seconds\fR、\fBclock scan\fR、或 \fBfile\fR 命令的 \fBatime\fR、 \fBmtime\fR、或 \fBctime\fR 選項返回的。如果 \fB-format\fR 參數存在,下一個參數是描述如何格式化日期和時間的一個字符串。字段描述符由一個 \fB%\fR 和隨後的字段描述符字符組成。所有的其他字符都複製到結果中。有效的字段描述符有: .RS .IP \fB%%\fR 插入一個 %。 .IP \fB%a\fR 星期名的縮寫 (Mon, Tue, etc.)。 .IP \fB%A\fR 完整的星期名 (Monday, Tuesday, etc.)。 .IP \fB%b\fR 月名的縮寫 (Jan, Feb, etc.)。 .IP \fB%B\fR 完整的月名。 .IP \fB%c\fR 特定於本地的日期和時間。 .IP \fB%d\fR 月中的第幾天 (01 - 31)。 .IP \fB%H\fR 24小時格式的小時(00 - 23)。 .IP \fB%I\fR 12小時格式的小時 (00 - 12)。 .IP \fB%j\fR 年中的第幾天 (001 - 366)。 .IP \fB%m\fR 第幾月 (01 - 12)。 .IP \fB%M\fR 分 (00 - 59)。 .IP \fB%p\fR AM/PM 指示符。 .IP \fB%S\fR 秒 (00 - 59)。 .IP \fB%U\fR 年中的第幾星期 (00 - 52),星期天是一個星期中的第一天。 .IP \fB%w\fR 星期幾 (Sunday = 0)。 .IP \fB%W\fR 年中的第幾星期 (00 - 52),星期一是一個星期中的第一天。 .IP \fB%x\fR 特定於本地的日期格式。 .IP \fB%X\fR 特定於本地的時間格式。 .IP \fB%y\fR 世紀中的第幾年 (00 - 99)。 .IP \fB%Y\fR 帶世紀的年 (例如 1990)。 .IP \fB%Z\fR 時區名。 .RE .sp .RS 在一些系統上支持下列補充的字段描述符(例如在 Unix 上而不在 Windows): .IP \fB%D\fR 形如 %m/%d/%y 的日期。 .IP \fB%e\fR 月中的第幾天 (1 - 31),沒有前導的零。 .IP \fB%h\fR 月名的縮寫。 .IP \fB%n\fR 插入一個換行。 .IP \fB%r\fR 形如 %I:%M:%S %p 的時間。 .IP \fB%R\fR 形如 %H:%M 的時間。 .IP \fB%t\fR 插入一個 tab。 .IP \fB%T\fR 形如 %H:%M:%S 的時間。 .RE .sp .RS 如果未指定 \fB-format\fR 參數,使用格式串 “\fB%a %b %d %H:%M:%S %Z %Y\fR”。如果 \fB-gmt\fR 參數存在,下一個參數必須是一個 boolean (值)。如果是真則指定時間作爲 Greenwich 標準時來格式化,如果是假則使用操作環境定義的本地時區。 .RE .TP \fBclock scan \fIdateString\fR ?\fB\-base \fIclockVal\fR? ?\fB\-gmt \fIboolean\fR? 把 \fIdateString\fR 轉換成一個整數時鐘值(參見 \fBclock seconds\fR)。這個命令可分析並轉換幾乎所有的標準的日期和/或時間串,其中可以包含標準的時區助記碼(mnemonic)。如果只指定了一個時間,假定爲當前的日期。如果串中不包括一個時區助記碼,除非 \fB-gmt \fR參數是真之外假定爲本地時區,在 \fB-gmt \fR 參數是真的情況下,假定指定的時間是相對於 Greenwich 標準時來計算時鐘值。如果指定了 \fB-gmt\fR,它隻影響計算出的時間值,不影響對 \fB-base \fR的解釋。 .sp 如果指定了 \fB-base\fR 標記,下一個參數將包括一個整數的時鐘值。只使用這個值中的日期而不管時間。這對確定特定的某天的時間或做其他的相對於日期的轉換有用。 .sp \fIdateString\fR 包含零個或多個下列形式的指定(specification): .RS .TP \fItime\fR 一天中的時間,樣式是: \fIhh\fR?\fI:mm\fR?\fI:ss\fR?? ?\fImeridian\fR? ?\fIzone\fR? or \fIhhmm \fR?\fImeridian\fR? ?\fIzone\fR?. 如果爲指定上下午(meridian), \fIhh\fR 被解釋爲一個24小時鐘點。 .TP \fIdate\fR 一個特定的月和日,年是可選的。可接受的格式是 \fImm/dd\fR?\fI/yy\fR?, \fImonthname dd\fR ?, \fIyy\fR?, \fIdd monthname \fR?\fIyy\fR?, \fIday, dd monthname yy\fR, \fI?CC?yymmdd\fR, \fI?CC?yy-mm-dd\fR, \fIdd-monthname-?CC?yy\fR. 缺省的年是當前年。如果年小於 .VS 100,我們把 00-68 年作爲 2000-2068 年而 69-99 年作爲 1969-1999 年。注意所有平臺都可以表示 38-70 年, 所以如果使用這些年就可能出錯。 .VE .TP \fIISO 8601 point-in-time\fR 一個 ISO 8601 point-in-time 指定,如 \fICCyymmddThhmmss\fR, 這裏 T 是字面的 T,\fICCyymmdd hhmmss\fR, 或者 \fICCyymmddThh:mm:ss\fR. .TP \fIrelative time\fR 相對當前時間的一個指定。格式是 \fInumber unit\fR,可接受的單位是 \fByear\fR、 \fBfortnight\fR、 \fBmonth\fR、 \fBweek\fR、 \fBday\fR、\fBhour\fR、 \fBminute\fR (或 \fBmin\fR)、和 \fBsecond\fR (或 \fBsec\fR)。單位可以被指定爲單數或複數,比如 \fB3 weeks\fR。還可以指定這些修飾符: \fBtomorrow\fR、 \fByesterday\fR、\fBtoday\fR、 \fBnow\fR、\fBlast\fR、\fBthis\fR、 \fBnext\fR、\fBago\fR。 .RE .sp .RS 實際的日期計算依照下列的步驟。首先,處理和轉換所有絕對日期和/或時間。使用這個時間作爲基準(base),添加上星期幾(day-of-week)指定。其次,使用相對指定。如果指定了一個日期或某天,並且沒有給出絕對或相對的時間,則使用午夜。最後,進行一次校正,這樣就在估計了夏令時不同之後產生正確的一天中的小時,並且在從一個大月結束到一個小月時給出正確的日期。 .sp 只在用如下單位指定相對時間的時候進行夏令時校正,日或更多,例如 days、 weeks、 fortnights、months 或 years。這意味着跨越夏令時邊界的時候,對 \fBclock scan “1 day”\fR 和 \fBclock scan “24 hours” \fR將給出不同的結果: .CS .ta 6c \fB% clock scan "1 day" -base [clock scan 1999-10-31] 941443200 % clock scan "24 hours" -base [clock scan 1999-10-31] 941439600\fR .CE .RE .TP \fBclock seconds\fR 把當前的日期和時間作爲依賴於系統的整數值返回。值的單位是秒,允許它被用於相對時間的計算。值通常被定義成從“epoch”開始(至今)總共流逝的時間。你不應該假定 epoch 的值。 .SH "關鍵字 KEYWORDS" clock, date, time .SH "[中文版維護人]" .B 寒蟬退士 .SH "[中文版最新更新]" .B 2001/06/21 .SH "《中國 Linux 論壇 man 手冊頁翻譯計劃》:" .BI http://cmpp.linuxforum.net .SH "跋" .br 本頁面中文版由中文 man 手冊頁計劃提供。 .br 中文 man 手冊頁計劃:\fBhttps://github.com/man-pages-zh/manpages-zh\fR