Difference between revisions of "Command/currentdate"

From Wiki
Jump to navigation Jump to search
(Added two examples for incrementing and decrementing \currentdate, wondering why the code only works for year and day but not for month...)
(Added another example and fixed typos.)
Line 89: Line 89:
 
</cd:description>
 
</cd:description>
 
<cd:examples><cd:example title="Example 1: The Current Date"><context source="yes" text="gives">
 
<cd:examples><cd:example title="Example 1: The Current Date"><context source="yes" text="gives">
 +
\currentdate
 +
 
\currentdate[weekday,month,day,{, },year]
 
\currentdate[weekday,month,day,{, },year]
  
 
\currentdate[day,{.~},month,{~},year]
 
\currentdate[day,{.~},month,{~},year]
 
</context></cd:example><cd:example title="Example 2: Incrementing and Decrementing the Current Date"><context source="yes" text="gives">
 
</context></cd:example><cd:example title="Example 2: Incrementing and Decrementing the Current Date"><context source="yes" text="gives">
Today it's \currentdate.\blank
+
Today is \currentdate.
  
 
\increment\normalday
 
\increment\normalday
  
Tomorrow will be \currentdate.\blank
+
Tomorrow will be \currentdate.
  
 
\decrement\normalday
 
\decrement\normalday
%\increment\normalmonth% -- gives and error
+
 
 +
%\increment\normalmonth% -- gives an error as of 08-2023
 
\increment\normalyear
 
\increment\normalyear
  
 
And today in a year will be \currentdate.
 
And today in a year will be \currentdate.
</context></cd:example><cd:example title="Example 3: Incrementing/Decrementing the Date Locally"><context source="yes" text="gives">
+
</context></cd:example><cd:example title="Example 3: Incrementing and Decrementing the Current Date Locally"><context source="yes" text="gives">
Today it's \currentdate.\blank
+
Today is \currentdate.
  
 
\start\increment\normalday
 
\start\increment\normalday
Tomorrow will be \currentdate.\blank
+
Tomorrow will be \currentdate.
 +
\stop
 +
 
 +
Yet today is \currentdate.
 +
</context></cd:example><cd:example title="Example 4: Incrementing and Decrementing the Current Date by N"><context source="yes" text="gives">
 +
Hello\dorecurse{1}{, Hello}.
 +
 
 +
Today is \currentdate.
 +
\start\increment\normalday
 +
So tomorrow will be \currentdate
 +
\stop
 +
\start\dorecurse{3}{\increment\normalday}
 +
and in three days will be \currentdate.
 
\stop
 
\stop
 +
Yet today is \currentdate.
 +
</context>
  
Yet today it's still \currentdate.
+
(Note the usage of line breaking and blank lines in the source code to fit the PDF product.)</cd:example></cd:examples>
</context></cd:example></cd:examples>
 
 
<cd:notes></cd:notes>
 
<cd:notes></cd:notes>
 
<cd:seealso>
 
<cd:seealso>

Revision as of 15:29, 25 August 2023


\currentdate

Summary

The command \currentdate typesets the current date.

Settings

\currentdate[...,...]
[...,...]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

OptionExplanation
This format is a comma-separated list of field formats and optional separators.

Settings name

\currentdate[...]
[...]name

OptionExplanation
This is a date format defined with \definedate

Description

The command \currentdate typesets the current date using a supplied format.



Examples

Example 1: The Current Date

\currentdate

\currentdate[weekday,month,day,{, },year]

\currentdate[day,{.~},month,{~},year]

gives

Example 2: Incrementing and Decrementing the Current Date

Today is \currentdate.

\increment\normalday

Tomorrow will be \currentdate.

\decrement\normalday

%\increment\normalmonth% -- gives an error as of 08-2023
\increment\normalyear

And today in a year will be \currentdate.

gives

Example 3: Incrementing and Decrementing the Current Date Locally

Today is \currentdate.

\start\increment\normalday
Tomorrow will be \currentdate.
\stop

Yet today is \currentdate.

gives

Example 4: Incrementing and Decrementing the Current Date by N

Hello\dorecurse{1}{, Hello}.

Today is \currentdate.
\start\increment\normalday
So tomorrow will be \currentdate
\stop
\start\dorecurse{3}{\increment\normalday}
and in three days will be \currentdate.
\stop
Yet today is \currentdate.

gives

(Note the usage of line breaking and blank lines in the source code to fit the PDF product.)

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: