1 @node Date input formats
2 @chapter Date input formats
4 @cindex date input formats
8 Our units of temporal measurement, from seconds on up to months, are so
9 complicated, asymmetrical and disjunctive so as to make coherent mental
10 reckoning in time all but impossible. Indeed, had some tyrannical god
11 contrived to enslave our minds to time, to make it all but impossible
12 for us to escape subjection to sodden routines and unpleasant surprises,
13 he could hardly have done better than handing down our present system.
14 It is like a set of trapezoidal building blocks, with no vertical or
15 horizontal surfaces, like a language in which the simplest thought
16 demands ornate constructions, useless particles and lengthy
17 circumlocutions. Unlike the more successful patterns of language and
18 science, which enable us to face experience boldly or at least
19 level-headedly, our system of temporal calculation silently and
20 persistently encourages our terror of time.
22 @dots{} It is as though architects had to measure length in feet, width
23 in meters and height in ells; as though basic instruction manuals
24 demanded a knowledge of five different languages. It is no wonder then
25 that we often look into our own immediate past or future, last Tuesday
26 or a week from Sunday, with feelings of helpless confusion. @dots{}
28 --- Robert Grudin, @cite{Time and the Art of Living}.
31 This section describes the textual date representations that GNU
32 programs accept. These are the strings you, as a user, can supply as
33 arguments to the various programs. The C interface (via the
34 @code{getdate} function) is not described here.
36 @cindex beginning of time, for Unix
37 @cindex epoch, for Unix
38 Although the date syntax here can represent any possible time since zero
39 A.D., computer integers are not big enough for such a (comparatively)
40 long time. The earliest date semantically allowed on Unix systems is
41 midnight, 1 January 1970 UCT.
44 * General date syntax:: Common rules.
45 * Calendar date item:: 19 Dec 1994.
46 * Time of day item:: 9:20pm.
47 * Timezone item:: EST, DST, BST, UCT, HAST, ...
48 * Day of week item:: Monday and others.
49 * Relative item in date strings:: next tuesday, 2 years ago.
50 * Pure numbers in date strings:: 19931219, 1440.
51 * Authors of getdate:: Bellovin, Salz, Berets, et al.
55 @node General date syntax
56 @section General date syntax
58 @cindex general date syntax
60 @cindex items in date strings
61 A @dfn{date} is a string, possibly empty, containing many items
62 separated by whitespace. The whitespace may be omitted when no
63 ambiguity arises. The empty string means the beginning of today (i.e.,
64 midnight). Order of the items is immaterial. A date string may contain
65 many flavors of items:
68 @item calendar date items
69 @item time of the day items
71 @item day of the week items
76 @noindent We describe each of these item types in turn, below.
78 @cindex numbers, written-out
79 @cindex ordinal numbers
80 @findex first @r{in date strings}
81 @findex next @r{in date strings}
82 @findex last @r{in date strings}
83 A few numbers may be written out in words in most contexts. This is
84 most useful for specifying day of the week items or relative items (see
85 below). Here is the list: @samp{first} for 1, @samp{next} for 2,
86 @samp{third} for 3, @samp{fourth} for 4, @samp{fifth} for 5,
87 @samp{sixth} for 6, @samp{seventh} for 7, @samp{eighth} for 8,
88 @samp{ninth} for 9, @samp{tenth} for 10, @samp{eleventh} for 11 and
89 @samp{twelfth} for 12. Also, @samp{last} means exactly @math{-1}.
91 @cindex months, written-out
92 When a month is written this way, it is still considered to be written
93 numerically, instead of being ``spelled in full''; this changes the
96 @cindex case, ignored in dates
97 @cindex comments, in dates
98 Alphabetic case is completely ignored in dates. Comments may be introduced
99 between round parentheses, as long as included parentheses are properly
100 nested. Hyphens not followed by a digit are currently ignored. Leading
101 zeros on numbers are ignored.
104 @node Calendar date item
105 @section Calendar date item
107 @cindex calendar date item
109 A @dfn{calendar date item} specifies a day of the year. It is
110 specified differently, depending on whether the month is specified
111 numerically or literally. All these strings specify the same calendar date:
114 1970-09-17 # ISO 8601.
115 70-9-17 # This century assumed by default.
116 70-09-17 # Leading zeros are ignored.
117 9/17/72 # Common U.S. writing.
119 24 Sept 72 # September has a special abbreviation.
120 24 Sep 72 # Three-letter abbreviations always allowed.
126 The year can also be omitted. In this case, the last specified year is
127 used, or the current year if none. For example:
136 @cindex ISO 8601 date format
137 @cindex date format, ISO 8601
138 For numeric months, the ISO 8601 format
139 @samp{@var{year}-@var{month}-@var{day}} is allowed, where @var{year} is
140 any positive number, @var{month} is a number between 01 and 12, and
141 @var{day} is a number between 01 and 31. A leading zero must be present
142 if a number is less than ten. If @var{year} is less than 100, then 1900
143 is added to it to force a date in this century. The construct
144 @samp{@var{month}/@var{day}/@var{year}}, popular in the United States,
145 is accepted. Also @samp{@var{month}/@var{day}}, omitting the year.
147 @cindex month names in date strings
148 @cindex abbreviations for months
149 Literal months may be spelled out in full: @samp{January},
150 @samp{February}, @samp{March}, @samp{April}, @samp{May}, @samp{June},
151 @samp{July}, @samp{August}, @samp{September}, @samp{October},
152 @samp{November} or @samp{December}. Literal months may be abbreviated
153 to their first three letters, possibly followed by an abbreviating dot.
154 It is also permitted to write @samp{Sept} instead of @samp{September}.
156 When months are written literally, the calendar date may be given as any
160 @var{day} @var{month} @var{year}
161 @var{day} @var{month}
162 @var{month} @var{day} @var{year}
163 @var{day}-@var{month}-@var{year}
166 Or, omitting the year:
169 @var{month} @var{day}
173 @node Time of day item
174 @section Time of day item
176 @cindex time of day item
178 A @dfn{time of day item} in date strings specifies the time on a given
179 day. Here are some examples, all of which represent the same time:
185 20:02-0500 # In EST (Eastern U.S. Standard Time).
188 More generally, the time of the day may be given as
189 @samp{@var{hour}:@var{minute}:@var{second}}, where @var{hour} is
190 a number between 0 and 23, @var{minute} is a number between 0 and
191 59, and @var{second} is a number between 0 and 59. Alternatively,
192 @samp{:@var{second}} can be omitted, in which case it is taken to
195 @findex am @r{in date strings}
196 @findex pm @r{in date strings}
197 @findex midnight @r{in date strings}
198 @findex noon @r{in date strings}
199 If the time is followed by @samp{am} or @samp{pm} (or @samp{a.m.}
200 or @samp{p.m.}), @var{hour} is restricted to run from 1 to 12, and
201 @samp{:@var{minute}} may be omitted (taken to be zero). @samp{am}
202 indicates the first half of the day, @samp{pm} indicates the second
203 half of the day. In this notation, 12 is the predecessor of 1:
204 midnight is @samp{12am} while noon is @samp{12pm}.
206 @cindex timezone correction
207 @cindex minutes, timezone correction by
208 The time may alternatively be followed by a timezone correction,
209 expressed as @samp{@var{s}@var{hh}@var{mm}}, where @var{s} is @samp{+}
210 or @samp{-}, @var{hh} is a number of zone hours and @var{mm} is a number
211 of zone minutes. When a timezone correction is given this way, it
212 forces interpretation of the time in UTC, overriding any previous
213 specification for the timezone or the local timezone. The @var{minute}
214 part of the time of the day may not be elided when a timezone correction
215 is used. This is the only way to specify a timezone correction by
216 fractional parts of an hour.
218 Either @samp{am}/@samp{pm} or a timezone correction may be specified,
223 @section Timezone item
225 @cindex timezone item
227 A @dfn{timezone item} specifies an international timezone, indicated by
228 a small set of letters. Any included period is ignored. Military
229 timezone designations use a single letter. Currently, only integral
230 zone hours may be represented in a timezone item. See the previous
231 section for a finer control over the timezone correction.
233 Here are many non-daylight-savings-time timezones, indexed by the zone
238 @cindex Greenwich Mean Time
239 @cindex Universal Coordinated Time
240 @cindex Western European Time
241 @samp{GMT} for Greenwich Mean, @samp{UT} or @samp{UTC} for Universal
242 (Coordinated), @samp{WET} for Western European and @samp{Z} for
245 @cindex West African Time
246 @samp{WAT} for West Africa and
247 @samp{A} for militaries.
250 @samp{AT} for Azores and @samp{B} for militaries.
252 @samp{C} for militaries.
254 @cindex Atlantic Standard Time
255 @samp{AST} for Atlantic Standard and @samp{D} for militaries.
257 @cindex Eastern Standard Time
258 @samp{E} for militaries and @samp{EST} for Eastern Standard.
260 @cindex Central Standard Time
261 @samp{CST} for Central Standard and @samp{F} for militaries.
263 @cindex Mountain Standard Time
264 @samp{G} for militaries and @samp{MST} for Mountain Standard.
266 @cindex Pacific Standard Time
267 @samp{H} for militaries and @samp{PST} for Pacific Standard.
269 @cindex Yukon Standard Time
270 @samp{I} for militaries and @samp{YST} for Yukon Standard.
272 @cindex Alaska-Hawaii Time
273 @cindex Central Alaska Time
274 @cindex Hawaii Standard Time
275 @samp{HAST} for Hawaii-Aleutian Standard, @samp{CAT} for Central Alaska,
276 @samp{HST} for Hawaii Standard and @samp{K} for militaries.
278 @cindex Nome Standard Time
279 @samp{L} for militaries and @samp{NT} for Nome.
281 @cindex International Date Line West
282 @samp{IDLW} for International Date Line West and @samp{M} for
285 @cindex Central European Time
286 @cindex Middle European Time
287 @cindex Middle European Winter Time
288 @cindex French Winter Time
289 @cindex Swedish Winter Time
290 @samp{CET} for Central European, @samp{FWT} for French Winter,
291 @samp{MET} for Middle European, @samp{MEWT} for Middle European
292 Winter, @samp{N} for militaries and @samp{SWT} for Swedish Winter.
294 @cindex Eastern European Time
296 @samp{EET} for Eastern European, USSR Zone 1 and @samp{O} for militaries.
299 @samp{BT} for Baghdad, USSR Zone 2 and @samp{P} for militaries.
301 @samp{Q} for militaries and @samp{ZP4} for USSR Zone 3.
303 @samp{R} for militaries and @samp{ZP5} for USSR Zone 4.
305 @samp{S} for militaries and @samp{ZP6} for USSR Zone 5.
307 @cindex West Australian Standard Time
308 @samp{T} for militaries and @samp{WAST} for West Australian Standard.
310 @cindex China Coast Time
311 @samp{CCT} for China Coast, USSR Zone 7 and @samp{U} for militaries.
313 @cindex Japan Standard Time
314 @samp{JST} for Japan Standard, USSR Zone 8 and @samp{V} for militaries.
316 @cindex East Australian Standard Time
317 @cindex Guam Standard Time
318 @samp{EAST} for East Australian Standard, @samp{GST} for Guam
319 Standard, USSR Zone 9 and @samp{W} for militaries.
321 @samp{X} for militaries.
323 @cindex International Date Line East
324 @cindex New Zealand Standard Time
325 @samp{IDLE} for International Date Line East, @samp{NZST} for
326 New Zealand Standard, @samp{NZT} for New Zealand and @samp{Y} for
330 @cindex daylight savings time
331 Here are many DST timezones, indexed by the zone hour value. Also, by
332 following a non-DST timezone by the string @samp{DST} in a separate word
333 (that is, separated by some whitespace), the corresponding DST timezone
338 @samp{BST} for British Summer.
340 @samp{ADT} for Atlantic Daylight.
342 @samp{EDT} for Eastern Daylight.
344 @samp{CDT} for Central Daylight.
346 @samp{MDT} for Mountain Daylight.
348 @samp{PDT} for Pacific Daylight.
350 @samp{YDT} for Yukon Daylight.
352 @samp{MEST} for Middle European Summer, @samp{MESZ} for Middle European
353 Summer, @samp{SST} for Swedish Summer and @samp{FST} for French Summer.
355 @samp{WADT} for West Australian Daylight.
357 @samp{EADT} for Eastern Australian Daylight.
359 @samp{NZDT} for New Zealand Daylight.
363 @node Day of week item
364 @section Day of week item
366 @cindex day of week item
368 The explicit mention of a day of the week will forward the date
369 (only if necessary) to reach that day of the week in the future.
371 Days of the week may be spelled out in full: @samp{Sunday},
372 @samp{Monday}, @samp{Tuesday}, @samp{Wednesday}, @samp{Thursday},
373 @samp{Friday} or @samp{Saturday}. Days may be abbreviated to their
374 first three letters, optionally followed by a period. The special
375 abbreviations @samp{Tues} for @samp{Tuesday}, @samp{Wednes} for
376 @samp{Wednesday} and @samp{Thur} or @samp{Thurs} for @samp{Thursday} are
379 @findex next @var{day}
380 @findex last @var{day}
381 A number may precede a day of the week item to move forward
382 supplementary weeks. It is best used in expression like @samp{third
383 monday}. In this context, @samp{last @var{day}} or @samp{next
384 @var{day}} is also acceptable; they move one week before or after
385 the day that @var{day} by itself would represent.
387 A comma following a day of the week item is ignored.
390 @node Relative item in date strings
391 @section Relative item in date strings
393 @cindex relative items in date strings
394 @cindex displacement of dates
396 @dfn{Relative items} adjust a date (or the current date if none) forward
397 or backward. The effects of relative items accumulate. Here are some
407 @findex year @r{in date strings}
408 @findex month @r{in date strings}
409 @findex fortnight @r{in date strings}
410 @findex week @r{in date strings}
411 @findex day @r{in date strings}
412 @findex hour @r{in date strings}
413 @findex minute @r{in date strings}
414 The unit of time displacement may be selected by the string @samp{year}
415 or @samp{month} for moving by whole years or months. These are fuzzy
416 units, as years and months are not all of equal duration. More precise
417 units are @samp{fortnight} which is worth 14 days, @samp{week} worth 7
418 days, @samp{day} worth 24 hours, @samp{hour} worth 60 minutes,
419 @samp{minute} or @samp{min} worth 60 seconds, and @samp{second} or
420 @samp{sec} worth one second. An @samp{s} suffix on these units is
421 accepted and ignored.
423 @findex ago @r{in date strings}
424 The unit of time may be preceded by a multiplier, given as an optionally
425 signed number. Unsigned numbers are taken as positively signed. No
426 number at all implies 1 for a multiplier. Following a relative item by
427 the string @samp{ago} is equivalent to preceding the unit by a
428 multiplicator with value @math{-1}.
430 @findex day @r{in date strings}
431 @findex tomorrow @r{in date strings}
432 @findex yesterday @r{in date strings}
433 The string @samp{tomorrow} is worth one day in the future (equivalent
434 to @samp{day}), the string @samp{yesterday} is worth
435 one day in the past (equivalent to @samp{day ago}).
437 @findex now @r{in date strings}
438 @findex today @r{in date strings}
439 @findex this @r{in date strings}
440 The strings @samp{now} or @samp{today} are relative items corresponding
441 to zero-valued time displacement, these strings come from the fact
442 a zero-valued time displacement represents the current time when not
443 otherwise change by previous items. They may be used to stress other
444 items, like in @samp{12:00 today}. The string @samp{this} also has
445 the meaning of a zero-valued time displacement, but is preferred in
446 date strings like @samp{this thursday}.
448 When a relative item makes the resulting date to cross the boundary
449 between DST and non-DST (or vice-versa), the hour is adjusted according
453 @node Pure numbers in date strings
454 @section Pure numbers in date strings
456 @cindex pure numbers in date strings
458 The precise intepretation of a pure decimal number is dependent of
459 the context in the date string.
461 If the decimal number is of the form @var{yyyy}@var{mm}@var{dd} and no
462 other calendar date item (@pxref{Calendar date item}) appears before it
463 in the date string, then @var{yyyy} is read as the year, @var{mm} as the
464 month number and @var{dd} as the day of the month, for the specified
467 If the decimal number is of the form @var{hh}@var{mm} and no other time
468 of day item appears before it in the date string, then @var{hh} is read
469 as the hour of the day and @var{mm} as the minute of the hour, for the
470 specified time of the day. @var{mm} can also be omitted.
472 If both a calendar date and a time of day appear to the left of a number
473 in the date string, but no relative item, then the number overrides the
477 @node Authors of getdate
478 @section Authors of @code{getdate}
480 @cindex authors of @code{getdate}
482 @cindex Bellovin, Steven M.
485 @cindex MacKenzie, David
486 @cindex Meyering, Jim
487 @code{getdate} was originally implemented by Steven M. Bellovin
488 (@samp{smb@@research.att.com}) while at the University of North Carolina
489 at Chapel Hill. The code was later tweaked by a couple of people on
490 Usenet, then completely overhauled by Rich $alz (@samp{rsalz@@bbn.com})
491 and Jim Berets (@samp{jberets@@bbn.com}) in August, 1990. Various
492 revisions for the GNU system were made by David MacKenzie, Jim Meyering,
497 This chapter was originally produced by Fran@,{c}ois Pinard
498 (@samp{pinard@@iro.umontreal.ca}) from the @file{getdate.y} source code,
499 and then edited by K.@: Berry (@samp{kb@@cs.umb.edu}).