Difference between revisions of "Command/date"

From Wiki
Jump to navigation Jump to search
(Removed the \v!-prefix for the label settings.)
 
(28 intermediate revisions by 12 users not shown)
Line 4: Line 4:
 
}}
 
}}
  
 +
== [[Help:Reference|Syntax]] (autogenerated) ==
 +
<syntax>date</syntax>
 
== [[Help:Reference|Syntax]] ==
 
== [[Help:Reference|Syntax]] ==
 
<table cellspacing="4" cellpadding="2" class="cmd">
 
<table cellspacing="4" cellpadding="2" class="cmd">
Line 10: Line 12:
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="first">
 
   <tr valign="top" class="first">
     <td class="cmd">[[Reference/en/keyword:d|d]]</td>
+
     <td class="cmd">[[Command/keyword:d|d]]</td>
     <td>[[Reference/en/value:number|number]] </td>
+
     <td>[[Command/value:number|number]] </td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="first">
 
   <tr valign="top" class="first">
     <td class="cmd">[[Reference/en/keyword:m|m]]</td>
+
     <td class="cmd">[[Command/keyword:m|m]]</td>
     <td>[[Reference/en/value:number|number]] </td>
+
     <td>[[Command/value:number|number]] </td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="first">
 
   <tr valign="top" class="first">
     <td class="cmd">[[Reference/en/keyword:y|y]]</td>
+
     <td class="cmd">[[Command/keyword:y|y]]</td>
     <td>[[Reference/en/value:number|number]] </td>
+
     <td>[[Command/value:number|number]] </td>
 
   </tr>
 
   </tr>
 
   <tr valign="top" class="second">
 
   <tr valign="top" class="second">
Line 33: Line 35:
 
The second optional argument specifies the output format.  Available fields are:
 
The second optional argument specifies the output format.  Available fields are:
  
''day'', ''month'', ''year'', weekday, dd, mm, yy, jj, d, m, y, j, referral.  
+
''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).
 
You can also insert delimiters between the fields (e.g. commas, spaces, see examples).
  
== Examples ==
+
== Example ==
 +
<context source="yes">
 +
\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
 +
</context>
 +
 
 +
To get a short month use <code>\monthshort</code>
 +
(lowercase, 25 apr 2008) or <code>\MONTHSHORT</code> (uppercase, 25 APR 2008) 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>\monthshort</code> form to have a starting capital (e.g. 25 Apr 2008).  Put the following in your environment file:
  
 
<texcode>
 
<texcode>
\date
+
\setuplabeltext
\date[d=25,m=4,y=2008]
+
  [en]
\date[d=25,m=4,y=2008][dd,--,mm,--,yy]
+
  [  january:mnem=Jan,
\date[d=25,m=4,y=2008][weekday,month,day,{,},year]
+
    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>
 
</texcode>
  
To get a short month use <texcode>\monthshort</texcode>  
+
To get a short weekday use <code>weekday:mnem</code>  
(lowercase, 25 apr 2008) or <texcode>\MONTHSHORT</texcode> (uppercase, 25 APR 2008) as follows:
+
(lowercase, fri 25 April 2008) as follows:
  
 
<texcode>
 
<texcode>
\date[d=25,m=4,y=2008][day,~,{\monthshort\normalmonth},~,year]
+
\date[d=25,m=4,y=2008][weekday:mnem,~,day,~,month,~,year] \par
\date[d=25,m=4,y=2008][day,~,{\MONTHSHORT\normalmonth},~,year]
 
 
</texcode>
 
</texcode>
  
It is possible to redefine the <texcode>\monthshort</texcode> form to have a starting capital (e.g. 25 Apr 2008).  Put the following in your environment file:
+
It is possible to redefine the <code>weekday:mnem</code> form to have a starting capital (e.g. Fri 25 April 2008).  Put the following in your environment file:
  
 
<texcode>
 
<texcode>
\unprotect
+
\setuplabeltext
\setuplabeltext [\s!en] [\v!january  :\s!mnem=Jan]
+
  [en]
\setuplabeltext [\s!en] [\v!february :\s!mnem=Feb]
+
  [   monday:mnem=Mon,
\setuplabeltext [\s!en] [\v!march    :\s!mnem=Mar]
+
     tuesday:mnem=Tue,
\setuplabeltext [\s!en] [\v!april    :\s!mnem=Apr]
+
  wednesday:mnem=Wed,
\setuplabeltext [\s!en] [\v!may     :\s!mnem=May]
+
     thursday:mnem=Thu,
\setuplabeltext [\s!en] [\v!june    :\s!mnem=Jun]
+
      friday:mnem=Fri,
\setuplabeltext [\s!en] [\v!july     :\s!mnem=Jul]
+
    saturday:mnem=Sat,
\setuplabeltext [\s!en] [\v!august  :\s!mnem=Aug]
+
      sunday:mnem=Sun]
\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
 
 
</texcode>
 
</texcode>
  
 +
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:
  
 +
<texcode>
 +
\setuplanguage [en] [date={year, –, mm, –, dd}]
 +
</texcode>
  
== Example ==
+
For non english the setuplanguage command should be followed or preceded by setting a mainlanguage or it will not show up.
<!-- Please fill in an example if you can -->
+
<texcode>
 +
\setuplanguage [nl] [date={dd, –, mm, –, year}]
 +
\mainlanguage [nl]
 +
</texcode>
  
 
== See also ==
 
== See also ==
<!-- something like [[cmd:goto|\goto]] -->
+
* {{cmd|currenttime}}
 +
* {{cmd|currentdate}}
 +
 
 +
== Help from ConTeXt-Mailinglist/Forum ==
 +
All issues with:
 +
{{Forum|{{SUBPAGENAME}}}}
  
[[Category:Reference/en|date]]
+
[[Category:Command/DateTime|date]]

Latest revision as of 09:08, 10 April 2020

\date

Syntax (autogenerated)

\date[...=...,...][...,...]
dnumber
mnumber
ynumber
[...,...]year year:name y y:name yy Y Y:name YY month month:mnem month:hebrew month:jalali m m:mnem m:hebrew m:jalali MONTH MONTH:mnem MONTH:hebrew MONTH:jalali mm M day day:name day:+ day:ord day:++ day:highord d d:name d:+ d:ord d:++ d:highord dd dd:+ dd:ord dd:++ dd:highord D D:+ D:ord D:++ D:highord weekday weekday:mnem weekday:hebrew weekday:jalali w w:mnem w:hebrew w:jalali WEEKDAY WEEKDAY:mnem WEEKDAY:hebrew WEEKDAY:jalali W referral space \\\\\\\\␣ text hebrew:to jalali:to jalali:from


\date[...=...,...][...]
dnumber
mnumber
ynumber
[...]name


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,~,month:mnem,~,year] \par
\date[d=25,m=4,y=2008][day,~,MONTH:mnem,~,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:

\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]

To get a short weekday use weekday:mnem (lowercase, fri 25 April 2008) as follows:

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

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

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

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: