Command/date

From Wiki
< Command
Revision as of 19:47, 8 April 2020 by Mæstro (talk | contribs) (→‎Example: -- add dayshort option from latest 2020-04-08 14:37)
Jump to navigation Jump to search

\date

Syntax (autogenerated)

\date[...=...,...][...,...]
dnumber
mnumber
ynumber
[...,...]inherits from \currentdate


Syntax

\date[...,...=...,...][...,...,...]
d number
m number
y number
[...,...,...]


Description

Display a date. First optional argument specifies the date using the day (d), month (m) and year (y). If omitted the current date is assumed.

The second optional argument specifies the output format. Available fields are:

day, day:ord [preferred] or day:+ (to get st, nd, rd, th, depends on language), month, year, weekday, dd, dd:ord/dd:+, mm, yy, jj, d, d:ord/d:+, m, y, j, referral.

You can also insert delimiters between the fields (e.g. commas, spaces, see examples).

Example

\date \par
\date[d=25,m=4,y=2008] \par 
\date[d=25,m=4,y=2008][dd,--,mm,--,yy] \par
\date[d=25,m=4,y=2008][weekday,month,day,{,~},year] \par

To get a short month use \monthshort (lowercase, 25 apr 2008) or \MONTHSHORT (uppercase, 25 APR 2008) as follows:

\date[d=25,m=4,y=2008][day,~,{\monthshort\normalmonth},~,year] \par
\date[d=25,m=4,y=2008][day,~,{\MONTHSHORT\normalmonth},~,year]

It is possible to redefine the \monthshort form to have a starting capital (e.g. 25 Apr 2008). Put the following in your environment file:

\unprotect
\setuplabeltext [\s!en] [\v!january  :\s!mnem=Jan]
\setuplabeltext [\s!en] [\v!february :\s!mnem=Feb]
\setuplabeltext [\s!en] [\v!march    :\s!mnem=Mar]
\setuplabeltext [\s!en] [\v!april    :\s!mnem=Apr]
\setuplabeltext [\s!en] [\v!may      :\s!mnem=May]
\setuplabeltext [\s!en] [\v!june     :\s!mnem=Jun]
\setuplabeltext [\s!en] [\v!july     :\s!mnem=Jul]
\setuplabeltext [\s!en] [\v!august   :\s!mnem=Aug]
\setuplabeltext [\s!en] [\v!september:\s!mnem=Sep]
\setuplabeltext [\s!en] [\v!october  :\s!mnem=Oct]
\setuplabeltext [\s!en] [\v!november :\s!mnem=Nov]
\setuplabeltext [\s!en] [\v!december :\s!mnem=Dec]
\protect

To get a short weekday use \dayshort (lowercase, fri, 25 April 2008) or \DAYSHORT (uppercase, FRI, 25 April 2008) as follows:

\date[d=25,m=4,y=2008][{\dayshort\normalday},{,~},day,~,month,~,year] \par
\date[d=25,m=4,y=2008][{\DAYSHORT\normalday},{,~},day,~,month,~,year]

It is possible to redefine the \dayshort form to have a starting capital (e.g. Fri, 25 April 2008). Put the following in your environment file:

\unprotect
\setuplabeltext [\s!en] [\v!monday    :\s!mnem=Mon]
\setuplabeltext [\s!en] [\v!tuesday   :\s!mnem=Tue]
\setuplabeltext [\s!en] [\v!wednesday :\s!mnem=Wed]
\setuplabeltext [\s!en] [\v!thursday  :\s!mnem=Thu]
\setuplabeltext [\s!en] [\v!friday    :\s!mnem=Fri]
\setuplabeltext [\s!en] [\v!saturday  :\s!mnem=Sat]
\setuplabeltext [\s!en] [\v!sunday    :\s!mnem=Sun]
\protect

To change the formatting of the date in a global fashion the command \setuplanguage is used. A change to ISO 8601 for instance can be achieved as follows:

\setuplanguage [en] [date={year, –, mm, –, dd}]

For non english the setuplanguage command should be followed or preceded by setting a mainlanguage or it will not show up.

\setuplanguage [nl] [date={dd, –, mm, –, year}]
\mainlanguage [nl]

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: