www.delorie.com/gnu/docs/calc/calc_168.html   search  
 
Buy the book!


GNU Emacs Calc 2.02 Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.7.7.1 Date Formatting Codes

When displaying a date, the current date format is used. All characters except for letters and `<' and `>' are copied literally when dates are formatted. The portion between `< >' markers is omitted for pure dates, or included for date/time forms. Letters are interpreted according to the table below.

When dates are read in during algebraic entry, Calc first tries to match the input string to the current format either with or without the time part. The punctuation characters (including spaces) must match exactly; letter fields must correspond to suitable text in the input. If this doesn't work, Calc checks if the input is a simple number; if so, the number is interpreted as a number of days since Jan 1, 1 AD. Otherwise, Calc tries a much more relaxed and flexible algorithm which is described in the next section.

Weekday names are ignored during reading.

Two-digit year numbers are interpreted as lying in the range from 1941 to 2039. Years outside that range are always entered and displayed in full. Year numbers with a leading `+' sign are always interpreted exactly, allowing the entry and display of the years 1 through 99 AD.

Here is a complete list of the formatting codes for dates:

Y
Year: "91" for 1991, "7" for 2007, "+23" for 23 AD.
YY
Year: "91" for 1991, "07" for 2007, "+23" for 23 AD.
BY
Year: "91" for 1991, " 7" for 2007, "+23" for 23 AD.
YYY
Year: "1991" for 1991, "23" for 23 AD.
YYYY
Year: "1991" for 1991, "+23" for 23 AD.
aa
Year: "ad" or blank.
AA
Year: "AD" or blank.
aaa
Year: "ad " or blank. (Note trailing space.)
AAA
Year: "AD " or blank.
aaaa
Year: "a.d." or blank.
AAAA
Year: "A.D." or blank.
bb
Year: "bc" or blank.
BB
Year: "BC" or blank.
bbb
Year: " bc" or blank. (Note leading space.)
BBB
Year: " BC" or blank.
bbbb
Year: "b.c." or blank.
BBBB
Year: "B.C." or blank.
M
Month: "8" for August.
MM
Month: "08" for August.
BM
Month: " 8" for August.
MMM
Month: "AUG" for August.
Mmm
Month: "Aug" for August.
mmm
Month: "aug" for August.
MMMM
Month: "AUGUST" for August.
Mmmm
Month: "August" for August.
D
Day: "7" for 7th day of month.
DD
Day: "07" for 7th day of month.
BD
Day: " 7" for 7th day of month.
W
Weekday: "0" for Sunday, "6" for Saturday.
WWW
Weekday: "SUN" for Sunday.
Www
Weekday: "Sun" for Sunday.
www
Weekday: "sun" for Sunday.
WWWW
Weekday: "SUNDAY" for Sunday.
Wwww
Weekday: "Sunday" for Sunday.
d
Day of year: "34" for Feb. 3.
ddd
Day of year: "034" for Feb. 3.
bdd
Day of year: " 34" for Feb. 3.
h
Hour: "5" for 5 AM; "17" for 5 PM.
hh
Hour: "05" for 5 AM; "17" for 5 PM.
bh
Hour: " 5" for 5 AM; "17" for 5 PM.
H
Hour: "5" for 5 AM and 5 PM.
HH
Hour: "05" for 5 AM and 5 PM.
BH
Hour: " 5" for 5 AM and 5 PM.
p
AM/PM: "a" or "p".
P
AM/PM: "A" or "P".
pp
AM/PM: "am" or "pm".
PP
AM/PM: "AM" or "PM".
pppp
AM/PM: "a.m." or "p.m.".
PPPP
AM/PM: "A.M." or "P.M.".
m
Minutes: "7" for 7.
mm
Minutes: "07" for 7.
bm
Minutes: " 7" for 7.
s
Seconds: "7" for 7; "7.23" for 7.23.
ss
Seconds: "07" for 7; "07.23" for 7.23.
bs
Seconds: " 7" for 7; " 7.23" for 7.23.
SS
Optional seconds: "07" for 7; blank for 0.
BS
Optional seconds: " 7" for 7; blank for 0.
N
Numeric date/time: "726842.25" for 6:00am Wed Jan 9, 1991.
n
Numeric date: "726842" for any time on Wed Jan 9, 1991.
J
Julian date/time: "2448265.75" for 6:00am Wed Jan 9, 1991.
j
Julian date: "2448266" for any time on Wed Jan 9, 1991.
U
Unix time: "663400800" for 6:00am Wed Jan 9, 1991.
X
Brackets suppression. An "X" at the front of the format causes the surrounding `< >' delimiters to be omitted when formatting dates. Note that the brackets are still required for algebraic entry.

If "SS" or "BS" (optional seconds) is preceded by a colon, the colon is also omitted if the seconds part is zero.

If "bb," "bbb" or "bbbb" or their upper-case equivalents appear in the format, then negative year numbers are displayed without a minus sign. Note that "aa" and "bb" are mutually exclusive. Some typical usages would be `YYYY AABB'; `AAAYYYYBBB'; `YYYYBBB'.

The formats "YY," "YYYY," "MM," "DD," "ddd," "hh," "HH," "mm," "ss," and "SS" actually match any number of digits during reading unless several of these codes are strung together with no punctuation in between, in which case the input must have exactly as many digits as there are letters in the format.

The "j," "J," and "U" formats do not make any time zone adjustment. They effectively use `julian(x,0)' and `unixtime(x,0)' to make the conversion; see section 8.5 Date Arithmetic.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003