Changes

Jump to navigation Jump to search
9,214 bytes added ,  09:53, 16 November 2021
Created page with "Documentation for \date"
<cd:commandgroup name="date" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807">
<cd:shortdesc>The command <tt>\date</tt> is used to typeset a formatted date
</cd:shortdesc>
<cd:variants>
<cd:command category="counter" file="core-con.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-conversion.xml" keywords="language" level="document" name="date" variantnumber="1">
<cd:arguments>
<cd:assignments list="yes" ordinal="1">
<cd:assignmentsdoc></cd:assignmentsdoc>
<cd:parameter name="d">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
<cd:parameter name="m">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
<cd:parameter name="y">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
</cd:assignments>
<cd:keywords list="yes" optional="yes" ordinal="2">
<cd:keywordsdoc></cd:keywordsdoc>
<cd:constant type="year">Year using arabic digits</cd:constant>
<cd:constant method="range" prefix="year" type="cd:name">Year using a defined conversion</cd:constant>
<cd:constant type="y">Alias for <cd:iref type="year"/></cd:constant>
<cd:constant method="range" prefix="y" type="cd:name"></cd:constant>
<cd:constant type="yy">Year using two arabic digits</cd:constant>
<cd:constant type="Y">Alias for <cd:iref type="year"/></cd:constant>
<cd:constant method="range" prefix="Y" type="cd:name"></cd:constant>
<cd:constant type="YY">Alias for <cd:iref type="yy"/></cd:constant>
<cd:constant type="month">Month using long name</cd:constant>
<cd:constant type="month:mnem">Month using mnemonic</cd:constant>
<cd:constant type="month:hebrew">Month name in Hebrew calendar</cd:constant>
<cd:constant type="month:jalali">Month name in Jalali calendar</cd:constant>
<cd:constant type="m">Alias for <cd:iref type="month"/></cd:constant>
<cd:constant type="m:mnem"></cd:constant>
<cd:constant type="m:hebrew"></cd:constant>
<cd:constant type="m:jalali"></cd:constant>
<cd:constant type="MONTH">Month using long name, in all uppercase</cd:constant>
<cd:constant type="MONTH:mnem"></cd:constant>
<cd:constant type="MONTH:hebrew"></cd:constant>
<cd:constant type="MONTH:jalali"></cd:constant>
<cd:constant type="mm">Month using two arabic digits</cd:constant>
<cd:constant type="M">Month using arabic digits</cd:constant>
<cd:constant type="day">Day using arabic digits</cd:constant>
<cd:constant method="range" prefix="day" type="cd:name">Day using a defined conversion</cd:constant>
<cd:constant type="day:+">Alias for <cd:iref type="day:ord"/></cd:constant>
<cd:constant type="day:ord">Day using arabic digits, with ordinal indicator suffix</cd:constant>
<cd:constant type="day:++">Alias for <cd:iref type="day:highord"/></cd:constant>
<cd:constant type="day:highord">Day using arabic digits, with ordinal indicator suffix in superscript</cd:constant>
<cd:constant type="d">Alias for <cd:iref type="day"/></cd:constant>
<cd:constant method="range" prefix="d" type="cd:name"></cd:constant>
<cd:constant type="d:+"></cd:constant>
<cd:constant type="d:ord"></cd:constant>
<cd:constant type="d:++"></cd:constant>
<cd:constant type="d:highord"></cd:constant>
<cd:constant type="dd">Day using two arabic digits</cd:constant>
<cd:constant type="dd:+"></cd:constant>
<cd:constant type="dd:ord"></cd:constant>
<cd:constant type="dd:++"></cd:constant>
<cd:constant type="dd:highord"></cd:constant>
<cd:constant type="D">Alias for <cd:iref type="day"/></cd:constant>
<cd:constant type="D:+"></cd:constant>
<cd:constant type="D:ord"></cd:constant>
<cd:constant type="D:++"></cd:constant>
<cd:constant type="D:highord"></cd:constant>
<cd:constant type="weekday">Weekday using long name</cd:constant>
<cd:constant type="weekday:mnem">Weekday using mnemonic</cd:constant>
<cd:constant type="weekday:hebrew"></cd:constant>
<cd:constant type="weekday:jalali"></cd:constant>
<cd:constant type="w">Alias for <cd:iref type="weekday"/></cd:constant>
<cd:constant type="w:mnem"></cd:constant>
<cd:constant type="w:hebrew"></cd:constant>
<cd:constant type="w:jalali"></cd:constant>
<cd:constant type="WEEKDAY">Weekday using long name, in all uppercase</cd:constant>
<cd:constant type="WEEKDAY:mnem"></cd:constant>
<cd:constant type="WEEKDAY:hebrew"></cd:constant>
<cd:constant type="WEEKDAY:jalali"></cd:constant>
<cd:constant type="W">Weekday using arabic digits</cd:constant>
<cd:constant type="referral">Date in iso format (yyyymmdd)</cd:constant>
<cd:constant type="space">Typesets a space as separator</cd:constant>
<cd:constant type="\\\\\\\\\\\\\\\\␣">Typesets a space as separator (actual input: <code>\ </code>, there is too much string quoting on the wiki)</cd:constant>
<cd:constant type="cd:text">Any user-supplied separator</cd:constant>
<cd:constant type="hebrew:to">Convert date to Hebrew calendar first</cd:constant>
<cd:constant type="jalali:to">Convert date to Jalali calendar first</cd:constant>
<cd:constant type="jalali:from">Convert date from Jalali calendar first</cd:constant>
</cd:keywords>
</cd:arguments>
</cd:command>
<cd:command category="counter" file="core-con.mkiv" interfacedate="2020-07-14T09:24" interfacefile="i-conversion.xml" keywords="language" level="document" name="date" variant="name" variantnumber="2">
<cd:arguments>
<cd:assignments list="yes" ordinal="1">
<cd:assignmentsdoc></cd:assignmentsdoc>
<cd:parameter name="d">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
<cd:parameter name="m">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
<cd:parameter name="y">
<cd:paramdoc></cd:paramdoc>
<cd:constant type="cd:number"></cd:constant>
</cd:parameter>
</cd:assignments>
<cd:keywords optional="yes" ordinal="2">
<cd:keywordsdoc></cd:keywordsdoc>
<cd:constant type="cd:name">This is a date format defined with {{cmd|definedate}}</cd:constant>
</cd:keywords>
</cd:arguments>
</cd:command>
</cd:variants>
<cd:description>Display a date. First argument specifies the date using the day (d), month (m) and year (y). If omitted the current date is assumed, but this is not officially supported. Use {{cmd|currentdate}} if you want the current date.

You can also insert delimiters between the fields (e.g. commas, spaces, see examples).</cd:description>
<cd:examples><cd:example title=""><context source="yes">
\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
</context>

To get a short month use <code>month:mnem</code> or <code>MONTH:mnem</code> as follows:

<context source="yes">
\date[d=25,m=4,y=2008][day,~,month:mnem,~,year] \par
\date[d=25,m=4,y=2008][day,~,MONTH:mnem,~,year]
</context>

It is possible to redefine the <code>month:mnem</code> form to have a starting capital (e.g. 25 Apr 2008). Put the following in your environment file:

<texcode>
\setuplabeltext
[en]
[ january:mnem=Jan,
february:mnem=Feb,
march:mnem=Mar,
april:mnem=Apr,
may:mnem=May,
june:mnem=Jun,
july:mnem=Jul,
august:mnem=Aug,
september:mnem=Sep,
october:mnem=Oct,
november:mnem=Nov,
december:mnem=Dec]
</texcode>

To get a short weekday use <code>weekday:mnem</code> as follows:

<texcode>
\date[d=25,m=4,y=2008][weekday:mnem,~,day,~,month,~,year] \par
</texcode>

It is possible to redefine the <code>weekday:mnem</code> form to have a starting capital. Put the following in your environment file:

<texcode>
\setuplabeltext
[en]
[ monday:mnem=Mon,
tuesday:mnem=Tue,
wednesday:mnem=Wed,
thursday:mnem=Thu,
friday:mnem=Fri,
saturday:mnem=Sat,
sunday:mnem=Sun]
</texcode>


</cd:example><cd:example title="Changing the default formatting">To change the formatting of the date in a global fashion the command {{cmd|setuplanguage}} is used. A change to ISO 8601 for instance can be achieved as follows:

<context source="yes" text="Produces">
\setuplanguage [en] [date={year, –, mm, –, dd}]

\date[d=25,m=4,y=2008]
</context>

For non english the setuplanguage command should be followed or preceded by setting a mainlanguage or it will not show up.
<texcode>
\setuplanguage [nl] [date={dd, –, mm, –, year}]
\mainlanguage [nl]
</texcode></cd:example></cd:examples>
<cd:notes></cd:notes>
<cd:seealso>
<cd:source file="core-con.mkiv" originator="system"></cd:source>
<cd:wikipage originator="system" page="Category:Counter"></cd:wikipage>
<cd:wikipage originator="system" page="Keywords:Language"></cd:wikipage>
<cd:commandref name="definedate"></cd:commandref>
<cd:commandref name="currentdate"></cd:commandref>
<cd:commandref name="setuplanguage"></cd:commandref></cd:seealso>
</cd:commandgroup>

Navigation menu