# [NTG-context] Datenumber

Bart Wise bntgcontext at wiseguysweb.com
Thu Nov 29 16:57:38 CET 2007

On Thursday November 29 2007, Mojca Miklavec wrote:
> On Nov 27, 2007 5:49 PM, Bart Wise wrote:
> > LaTeX has a package called datenumber.  It basically allows you to
> > several things:
> >
> > 1) convert a date into a number,
>
> What number? What's the input and what's the output?

First you set the date:
\setdatenumber{year}{month}{day}
Example: \setdatenumber{2007}{1}{5}

Internally, this sets a counter called datenumber.
You print the date with \datedate.

Then, to increment by a week, you would add 7 to the datenumber and set the
date as follows:
\setdatebynumber{\thedatenumber}

I made a function that increments the date:
\def\IncDate{%
\setdatebynumber{\thedatenumber}%
}%

Then, I created a table with the first column entries as follows:
\datedate\IncDate
\datedate\IncDate
\datedate\IncDate
\datedate\IncDate
\datedate\IncDate
...

The output would be:
Friday, 5 January, 2007
Friday, 12 January, 2007
Friday, 19 January, 2007
Friday, 26 January, 2007
Friday, 2 February, 2007

This way I do not have to put in anything except the first date and dates for
the whole year are calculated and printed for me.

>
> > 2) add and subtract from that
> > number, in essence adding and subtracting days, and
> >
> > 3) converting a date number into a date string.
>
> The manual mentions this example
>     \date[d=17,m=11,y=2007][weekday,month,day,{, },year]
>
> or simply
>     \date[y=2007,m=11,d=27]
> or
>     \currentdate

As best as I can tell, this only sets the date.  I can see of no way to add a
given number of days to calculate a new date.

>
> > I use this package to create a yearly lesson
> > schedule and various other similiar things.  However, I have spent a
> > considerable amount of time trying to find the same functionality in
> > ConTeXt with no avail. Is there a solution for this?
>
> There are quite some macros in tex/context/base/core-con.tex (&
> core-con.mkii) devoted to that. I didn't play with substraction yet,
> but I bet there is some simple way to do it.

I looked through the source code of core-con.mkii, core-con.mkiv and
core-con.tex.  I don't see the functionality I need already constructed.  I
was hoping that an existing solution existed without the need for creating
new code.

>
> Mojca

Thanks for you help.  If I overlooked something, let me know.
Bart