ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* printing the current date
@ 2021-01-10 18:23 Peter Münster
  2021-01-10 18:25 ` Fabrice L
  2021-01-27 17:28 ` Peter Münster
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Münster @ 2021-01-10 18:23 UTC (permalink / raw)
  To: ConTeXt users

Hi,

I would expect, that \currentdate prints the current date, but it does
not:

--8<---------------cut here---------------start------------->8---
\starttext
\date[d=1]% first day of this month, ok

\date% again first day, last parameters are used, this is ok

\currentdate% same as \date, but I would expect the day of today...
\stoptext
--8<---------------cut here---------------end--------------->8---

How could I print the current date please?

TIA for any hints,
-- 
           Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: printing the current date
  2021-01-10 18:23 printing the current date Peter Münster
@ 2021-01-10 18:25 ` Fabrice L
  2021-01-10 19:26   ` Peter Münster
  2021-01-27 17:28 ` Peter Münster
  1 sibling, 1 reply; 8+ messages in thread
From: Fabrice L @ 2021-01-10 18:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users



> Le 10 janv. 2021 à 13:23, Peter Münster <pm@a16n.net> a écrit :
> 
> Hi,
> 
> I would expect, that \currentdate prints the current date, but it does
> not:
> 
> --8<---------------cut here---------------start------------->8---
> \starttext
> \date[d=1]% first day of this month, ok
> 
> \date% again first day, last parameters are used, this is ok
> 
> \currentdate% same as \date, but I would expect the day of today...
> \stoptext
> --8<---------------cut here---------------end--------------->8---
> 
> How could I print the current date please?

For exemple:

 \date[][weekday,day,month,year] and \currenttime[h,{\,:\,},m] 

F.

> 
> TIA for any hints,
> -- 
>           Peter
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: printing the current date
  2021-01-10 18:25 ` Fabrice L
@ 2021-01-10 19:26   ` Peter Münster
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Münster @ 2021-01-10 19:26 UTC (permalink / raw)
  To: ConTeXt users

On Sun, Jan 10 2021, Fabrice L wrote:

> For exemple:
>
>  \date[][weekday,day,month,year] and \currenttime[h,{\,:\,},m] 

Sorry, I should have mentioned, that I use the latest version:
context-2021.01.08

-- 
           Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: printing the current date
  2021-01-10 18:23 printing the current date Peter Münster
  2021-01-10 18:25 ` Fabrice L
@ 2021-01-27 17:28 ` Peter Münster
  2021-01-27 21:31   ` Hans Hagen
  1 sibling, 1 reply; 8+ messages in thread
From: Peter Münster @ 2021-01-27 17:28 UTC (permalink / raw)
  To: ConTeXt users

On Sun, Jan 10 2021, Peter Münster wrote:

> \currentdate% same as \date, but I would expect the day of today...

Should I fill a bug-report on the tracker?
Perhaps also for the missing space after \date[]?

TIA,
-- 
           Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: printing the current date
  2021-01-27 17:28 ` Peter Münster
@ 2021-01-27 21:31   ` Hans Hagen
  2021-01-27 22:48     ` Wolfgang Schuster
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2021-01-27 21:31 UTC (permalink / raw)
  To: ConTeXt users

On 1/27/2021 6:28 PM, Peter Münster wrote:
> On Sun, Jan 10 2021, Peter Münster wrote:
> 
>> \currentdate% same as \date, but I would expect the day of today...
> 
> Should I fill a bug-report on the tracker?
> Perhaps also for the missing space after \date[]?
Reporting here is faster. Can (lazy me) Wolfgang confirm the issue?

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: printing the current date
  2021-01-27 21:31   ` Hans Hagen
@ 2021-01-27 22:48     ` Wolfgang Schuster
  2021-03-12 23:10       ` missing space after \date[] (was: printing the current date) Peter Münster
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Schuster @ 2021-01-27 22:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hans Hagen schrieb am 27.01.2021 um 22:31:
> On 1/27/2021 6:28 PM, Peter Münster wrote:
>> On Sun, Jan 10 2021, Peter Münster wrote:
>>
>>> \currentdate% same as \date, but I would expect the day of today...
>>
>> Should I fill a bug-report on the tracker?
>> Perhaps also for the missing space after \date[]?
>
> Reporting here is faster. Can (lazy me) Wolfgang confirm the issue?


1. Wrong date

The \date command has wrong/weird grouping which makes global changes 
for the day, month and year.

\permanent\tolerant\protected\def\date[#1]#*[#2]%
   {\dontleavehmode
    \ifparameter#1\or
      \begingroup
      \letdummyparameter\c!d\normalday
      \letdummyparameter\c!m\normalmonth
      \letdummyparameter\c!y\normalyear
      \getdummyparameters[#1]%
      \normalexpanded
        {\endgroup
         \normalday  \number\directdummyparameter\c!d\relax
         \normalmonth\number\directdummyparameter\c!m\relax
         \normalyear \number\directdummyparameter\c!y\relax}%
    \fi
    ...}


2. Missing space

When not all optional arguments are used the space after the last given 
argument is gobbled. This was normal behavior for a long time until you 
changed the code in MkIV to keep them.


\tolerant\def\foo[#1]#*[#2]%
   {[#1][#2]}

\starttext

a \foo [1] b

a \foo [1] [2] b

\stoptext


Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* missing space after \date[] (was: printing the current date)
  2021-01-27 22:48     ` Wolfgang Schuster
@ 2021-03-12 23:10       ` Peter Münster
  2021-03-13  9:08         ` Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Münster @ 2021-03-12 23:10 UTC (permalink / raw)
  To: ntg-context

On Wed, Jan 27 2021, Wolfgang Schuster wrote:

> When not all optional arguments are used the space after the last
> given argument is gobbled. This was normal behavior for a long time
> until you changed the code in MkIV to keep them.

Hi,

What does that mean? Is that going to be changed?
How should \date[] be used now in the text?
For now, I do it like "bla \date[d=3]\ bla".
Is there a nicer way?

TIA for any hints,
-- 
           Peter
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: missing space after \date[] (was: printing the current date)
  2021-03-12 23:10       ` missing space after \date[] (was: printing the current date) Peter Münster
@ 2021-03-13  9:08         ` Hans Hagen
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen @ 2021-03-13  9:08 UTC (permalink / raw)
  To: ntg-context

On 3/13/2021 12:10 AM, Peter Münster wrote:
> On Wed, Jan 27 2021, Wolfgang Schuster wrote:
> 
>> When not all optional arguments are used the space after the last
>> given argument is gobbled. This was normal behavior for a long time
>> until you changed the code in MkIV to keep them.
> 
> Hi,
> 
> What does that mean? Is that going to be changed?
> How should \date[] be used now in the text?
> For now, I do it like "bla \date[d=3]\ bla".
> Is there a nicer way?
> 
> TIA for any hints,
The problem with an interface with optional arguments is that it has to 
look ahead. There are actually some macros that use this feature to get 
rid of upcoming spaces (picking up two optional arguments where one is 
needed). So, no matter what solution is chosen: push back a space or 
not, it has some unpredictable character.

This is why I always am explicit, as in \date[d=3]\ bla because no 
matter what happens bvehind the screens, the \ terminates the argument 
check so it will stay. (I admit that i'm mnore often bitten by the 
pushed back one than the gobbled one so i make it a habit to be explicit 
about spaces, like like i use \removeunwantedspaces when i'm not sure
when there can be spaces that crept in).

We can of course in lmtx bring back the 'push back a space' behaviour 
but we then also introduce some fuzzyness. Now we have "we scan upto n 
arguments and gobble spaces when doing so".

Btw, there is also another aspect: when looking for optional arguments 
the next token gets looked at and that one can be in an upcoming macro 
or content.

\startfoo[a][b]
    content
\stopfoo

\startfoo[a]
    [ that starts content
\stopfoo

so sometimes one needs

\startfoo[a]
    \relax [ that starts content
\stopfoo

to abort the scanning.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-13  9:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10 18:23 printing the current date Peter Münster
2021-01-10 18:25 ` Fabrice L
2021-01-10 19:26   ` Peter Münster
2021-01-27 17:28 ` Peter Münster
2021-01-27 21:31   ` Hans Hagen
2021-01-27 22:48     ` Wolfgang Schuster
2021-03-12 23:10       ` missing space after \date[] (was: printing the current date) Peter Münster
2021-03-13  9:08         ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).