2 @set Francois Franc,ois
5 @set Francois Fran\noexpand\ptexc cois
8 @node Date input formats
9 @chapter Date input formats
11 @cindex date input formats
14 This section describes the textual date representations that GNU
15 programs accept. These are the strings you, as a user, can supply as
16 arguments to the various programs. The C interface (via the
17 @code{getdate} function) is not described here.
19 @cindex beginning of time, for Unix
20 @cindex epoch, for Unix
21 Although the date syntax here can represent any possible time since zero
22 A.D., computer integers are not big enough for such a (comparatively)
23 long time. The earliest date semantically allowed on Unix systems is
24 midnight, 1 January 1970 UCT.
27 * General date syntax:: Common rules.
28 * Calendar date item:: 19 Dec 1994.
29 * Time of day item:: 9:20pm.
30 * Timezone item:: EST, DST, BST, UCT, AHST, ...
31 * Day of week item:: Monday and others.
32 * Relative item in date strings:: next tuesday, 2 years ago.
33 * Pure numbers in date strings:: 19931219, 1440.
34 * Authors of getdate:: Bellovin, Salz, Berets, et al.
38 @node General date syntax
39 @section General date syntax
41 @cindex general date syntax
43 @cindex items in date strings
44 A @dfn{date} is a string, possibly empty, containing many items
45 separated by whitespace. The whitespace may be omitted when no
46 ambiguity arises. The empty string means the beginning of today (i.e.,
47 midnight). Order of the items is immaterial. A date string may contain
48 many flavors of items:
51 @item calendar date items
52 @item time of the day items
54 @item day of the week items
59 @noindent We describe each of these item types in turn, below.
61 @cindex numbers, written-out
62 @cindex ordinal numbers
63 @findex first @r{in date strings}
64 @findex next @r{in date strings}
65 @findex last @r{in date strings}
66 A few numbers may be written out in words in most contexts. This is
67 most useful for specifying day of the week items or relative items (see
68 below). Here is the list: @samp{first} for 1, @samp{next} for 2,
69 @samp{third} for 3, @samp{fourth} for 4, @samp{fifth} for 5,
70 @samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
71 @samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
72 @samp{twelfth} for 12. Also, @samp{last} means exactly @math{-1}.
74 @cindex months, written-out
75 When a month is written this way, it is still considered to be written
76 numerically, instead of being ``spelled in full''; this changes the
79 @cindex case, ignored in dates
80 @cindex comments, in dates
81 Alphabetic case is completely ignored in dates. Comments may be introduced
82 between round parentheses, as long as included parentheses are properly
83 nested. Hyphens not followed by a digit are currently ignored. Leading
84 zeros on numbers are ignored.
87 @node Calendar date item
88 @section Calendar date item
90 @cindex calendar date item
92 A @dfn{calendar date item} specifies a day of the year. It is
93 specified differently, depending on whether the month is specified
94 numerically or literally. All these strings specify the same calendar date:
97 1970-09-17 # ISO 8601.
98 70-9-17 # This century assumed by default.
99 70-09-17 # Leading zeros are ignored.
100 9/17/72 # Common U.S. writing.
102 24 Sept 72 # September has a special abbreviation.
103 24 Sep 72 # Three-letter abbreviations always allowed.
109 The year can also be omitted. In this case, the last specified year is
110 used, or the current year if none. For example:
119 @cindex ISO 8601 date format
120 @cindex date format, ISO 8601
121 For numeric months, the ISO 8601 format
122 @samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
123 any positive number, @var{month} is a number between 01 and 12, and
124 @var{day} is a number between 01 and 31. A leading zero must be present
125 if a number is less than ten. If @var{year} is less than 100, then 1900
126 is added to it to force a date in this century. The construct
127 @samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
128 is accepted. Also @samp{@var{month}/@var{day}}, omitting the year.
130 @cindex month names in date strings
131 @cindex abbreviations for months
132 Literal months may be spelled out in full: @samp{January},
133 @samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
134 @samp{July}, @samp{August}, @samp{September}, @samp{October},
135 @samp{November} or @samp{December}. Literal months may be abbreviated
136 to their first three letters, possibly followed by an abbreviating dot.
137 It is also permitted to write @samp{Sept} instead of @samp{September}.
139 When months are written literally, the calendar date may be given as any
143 @var{day} @var{month} @var{year}
144 @var{day} @var{month}
145 @var{month} @var{day} @var{year}
146 @var{day}-@var{month}-@var{year}
149 Or, omitting the year:
152 @var{month} @var{day}
156 @node Time of day item
157 @section Time of day item
159 @cindex time of day item
161 A @dfn{time of day item} in date strings specifies the time on a given
162 day. Here are some examples, all of which represent the same time:
168 20:02-0500 # In EST (Eastern U.S. Standard Time).
171 More generally, the time of the day may be given as
172 @samp{@var{hour}:@var{minute}:@var{second}}, where @var{hour} is
173 a number between 0 and 23, @var{minute} is a number between 0 and
174 59, and @var{second} is a number between 0 and 59. Alternatively,
175 @samp{:@var{second}} can be omitted, in which case it is taken to
178 @findex am @r{in date strings}
179 @findex pm @r{in date strings}
180 @findex midnight @r{in date strings}
181 @findex noon @r{in date strings}
182 If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
183 or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
184 @samp{:@var{minute}} may be omitted (taken to be zero). @samp{am}
185 indicates the first half of the day, @samp{pm} indicates the second
186 half of the day. In this notation, 12 is the predecessor of 1:
187 midnight is @samp{12am} while noon is @samp{12pm}.
189 @cindex timezone correction
190 @cindex minutes, timezone correction by
191 The time may alternatively be followed by a timezone correction,
192 expressed as @samp{@var{s}@var{hh}@var{mm}}, where @var{s} is @samp{+}
193 or @samp{-}, @var{hh} is a number of zone hours and @var{mm} is a number
194 of zone minutes. When a timezone correction is given this way, it
195 forces interpretation of the time in UTC, overriding any previous
196 specification for the timezone or the local timezone. The @var{minute}
197 part of the time of the day may not be elided when a timezone correction
198 is used. This is the only way to specify a timezone correction by
199 fractional parts of an hour.
201 Either @samp{am}/@samp{pm} or a timezone correction may be specified,
206 @section Timezone item
208 @cindex timezone item
210 A @dfn{timezone item} specifies an international timezone, indicated by
211 a small set of letters. Any included period is ignored. Military
212 timezone designations use a single letter. Currently, only integral
213 zone hours may be represented in a timezone item. See the previous
214 section for a finer control over the timezone correction.
216 Here are many non-daylight-savings-time timezones, indexed by the zone
221 @cindex Greenwich Mean Time
222 @cindex Universal Coordinated Time
223 @cindex Western European Time
224 @samp{GMT} for Greenwich Mean, @samp{UT} or @samp{UTC} for Universal
225 (Coordinated), @samp{WET} for Western European and @samp{Z} for
228 @cindex West African Time
229 @samp{WAT} for West Africa and
230 @samp{A} for militaries.
233 @samp{AT} for Azores and @samp{B} for militaries.
235 @samp{C} for militaries.
237 @cindex Atlantic Standard Time
238 @samp{AST} for Atlantic Standard and @samp{D} for militaries.
240 @cindex Eastern Standard Time
241 @samp{E} for militaries and @samp{EST} for Eastern Standard.
243 @cindex Central Standard Time
244 @samp{CST} for Central Standard and @samp{F} for militaries.
246 @cindex Mountain Standard Time
247 @samp{G} for militaries and @samp{MST} for Mountain Standard.
249 @cindex Pacific Standard Time
250 @samp{H} for militaries and @samp{PST} for Pacific Standard.
252 @cindex Yukon Standard Time
253 @samp{I} for militaries and @samp{YST} for Yukon Standard.
255 @cindex Alaska-Hawaii Time
256 @cindex Central Alaska Time
257 @cindex Hawaii Standard Time
258 @samp{AHST} for Alaska-Hawaii Standard, @samp{CAT} for Central Alaska,
259 @samp{HST} for Hawaii Standard and @samp{K} for militaries.
261 @cindex Nome Standard Time
262 @samp{L} for militaries and @samp{NT} for Nome.
264 @cindex International Date Line West
265 @samp{IDLW} for International Date Line West and @samp{M} for
268 @cindex Central European Time
269 @cindex Middle European Time
270 @cindex Middle European Winter Time
271 @cindex French Winter Time
272 @cindex Swedish Winter Time
273 @samp{CET} for Central European, @samp{FWT} for French Winter,
274 @samp{MET} for Middle European, @samp{MEWT} for Middle European
275 Winter, @samp{N} for militaries and @samp{SWT} for Swedish Winter.
277 @cindex Eastern European Time
279 @samp{EET} for Eastern European, USSR Zone 1 and @samp{O} for militaries.
282 @samp{BT} for Baghdad, USSR Zone 2 and @samp{P} for militaries.
284 @samp{Q} for militaries and @samp{ZP4} for USSR Zone 3.
286 @samp{R} for militaries and @samp{ZP5} for USSR Zone 4.
288 @samp{S} for militaries and @samp{ZP6} for USSR Zone 5.
290 @cindex West Australian Standard Time
291 @samp{T} for militaries and @samp{WAST} for West Australian Standard.
293 @cindex China Coast Time
294 @samp{CCT} for China Coast, USSR Zone 7 and @samp{U} for militaries.
296 @cindex Japan Standard Time
297 @samp{JST} for Japan Standard, USSR Zone 8 and @samp{V} for militaries.
299 @cindex East Australian Standard Time
300 @cindex Guam Standard Time
301 @samp{EAST} for East Australian Standard, @samp{GST} for Guam
302 Standard, USSR Zone 9 and @samp{W} for militaries.
304 @samp{X} for militaries.
306 @cindex International Date Line East
307 @cindex New Zealand Standard Time
308 @samp{IDLE} for International Date Line East, @samp{NZST} for
309 New Zealand Standard, @samp{NZT} for New Zealand and @samp{Y} for
313 @cindex daylight savings time
314 Here are many DST timezones, indexed by the zone hour value. Also, by
315 following a non-DST timezone by the string @samp{DST} in a separate word
316 (that is, separated by some whitespace), the corresponding DST timezone
321 @samp{BST} for British Summer.
323 @samp{ADT} for Atlantic Daylight.
325 @samp{EDT} for Eastern Daylight.
327 @samp{CDT} for Central Daylight.
329 @samp{MDT} for Mountain Daylight.
331 @samp{PDT} for Pacific Daylight.
333 @samp{YDT} for Yukon Daylight.
335 @samp{HDT} for Hawaii Daylight.
337 @samp{MEST} for Middle European Summer, @samp{MESZ} for Middle European
338 Summer, @samp{SST} for Swedish Summer and @samp{FST} for French Summer.
340 @samp{WADT} for West Australian Daylight.
342 @samp{EADT} for Eastern Australian Daylight.
344 @samp{NZDT} for New Zealand Daylight.
348 @node Day of week item
349 @section Day of week item
351 @cindex day of week item
353 The explicit mention of a day of the week will forward the date
354 (only if necessary) to reach that day of the week in the future.
356 Days of the week may be spelled out in full: @samp{Sunday},
357 @samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
358 @samp{Friday} or @samp{Saturday}. Days may be abbreviated to their
359 first three letters, optionally followed by a period. The special
360 abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
361 @samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
364 @findex next @var{day}
365 @findex last @var{day}
366 A number may precede a day of the week item to move forward
367 supplementary weeks. It is best used in expression like @samp{third
368 monday}. In this context, @samp{last @var{day}} or @samp{next
369 @var{day}} is also acceptable; they move one week before or after
370 the day that @var{day} by itself would represent.
372 A comma following a day of the week item is ignored.
375 @node Relative item in date strings
376 @section Relative item in date strings
378 @cindex relative items in date strings
379 @cindex displacement of dates
381 @dfn{Relative items} adjust a date (or the current date if none) forward
382 or backward. The effects of relative items accumulate. Here are some
392 @findex year @r{in date strings}
393 @findex month @r{in date strings}
394 @findex fortnight @r{in date strings}
395 @findex week @r{in date strings}
396 @findex day @r{in date strings}
397 @findex hour @r{in date strings}
398 @findex minute @r{in date strings}
399 The unit of time displacement may be selected by the string @samp{year}
400 or @samp{month} for moving by whole years or months. These are fuzzy
401 units, as years and months are not all of equal duration. More precise
402 units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
403 days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
404 @samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
405 @samp{sec} worth one second. An @samp{s} suffix on these units is
406 accepted and ignored.
408 @findex ago @r{in date strings}
409 The unit of time may be preceded by a multiplier, given as an optionally
410 signed number. Unsigned numbers are taken as positively signed. No
411 number at all implies 1 for a multiplier. Following a relative item by
412 the string @samp{ago} is equivalent to preceding the unit by a
413 multiplicator with value @math{-1}.
415 @findex day @r{in date strings}
416 @findex tomorrow @r{in date strings}
417 @findex yesterday @r{in date strings}
418 The string @samp{tomorrow} is worth one day in the future (equivalent
419 to @samp{day}), the string @samp{yesterday} is worth
420 one day in the past (equivalent to @samp{day ago}).
422 @findex now @r{in date strings}
423 @findex today @r{in date strings}
424 @findex this @r{in date strings}
425 The strings @samp{now} or @samp{today} are relative items corresponding
426 to zero-valued time displacement, these strings come from the fact
427 a zero-valued time displacement represents the current time when not
428 otherwise change by previous items. They may be used to stress other
429 items, like in @samp{12:00 today}. The string @samp{this} also has
430 the meaning of a zero-valued time displacement, but is preferred in
431 date strings like @samp{this thursday}.
433 When a relative item makes the resulting date to cross the boundary
434 between DST and non-DST (or vice-versa), the hour is adjusted according
438 @node Pure numbers in date strings
439 @section Pure numbers in date strings
441 @cindex pure numbers in date strings
443 The precise intepretation of a pure decimal number is dependent of
444 the context in the date string.
446 If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
447 other calendar date item (@pxref{Calendar date item}) appears before it
448 in the date string, then @var{yyyy} is read as the year, @var{mm} as the
449 month number and @var{dd} as the day of the month, for the specified
452 If the decimal number is of the form @var{hh}@var{mm} and no other time
453 of day item appears before it in the date string, then @var{hh} is read
454 as the hour of the day and @var{mm} as the minute of the hour, for the
455 specified time of the day. @var{mm} can also be omitted.
457 If both a calendar date and a time of day appear to the left of a number
458 in the date string, but no relative item, then the number overrides the
462 @node Authors of getdate
463 @section Authors of @code{getdate}
465 @cindex authors of @code{getdate}
467 @cindex Bellovin, Steven M.
470 @cindex MacKenzie, David
471 @cindex Meyering, Jim
472 @code{getdate} was originally implemented by Steven M. Bellovin
473 (@samp{smb@@research.att.com}) while at the University of North Carolina
474 at Chapel Hill. The code was later tweaked by a couple of people on
475 Usenet, then completely overhauled by Rich $alz (@samp{rsalz@@bbn.com})
476 and Jim Berets (@samp{jberets@@bbn.com}) in August, 1990. Various
477 revisions for the GNU system were made by David MacKenzie, Jim Meyering,
482 This chapter was originally produced by @value{Francois} Pinard
483 (@samp{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,
484 and then edited by K.@: Berry (@samp{kb@@cs.umb.edu}).