From: Benjamin Buchmuller <benjamin.buchmuller@gmail.com>
To: Hans Hagen <j.hagen@xs4all.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Re: \time pendant to \currenttime
Date: Tue, 10 Jun 2025 12:54:03 -0400 [thread overview]
Message-ID: <4196426B-E2D2-4FB8-8B8D-91AF9F73D2B7@gmail.com> (raw)
In-Reply-To: <8390cdfc-cc73-4a8a-9e27-ca5ce12ea278@xs4all.nl>
Hi Hans,
Thanks for sharing this so quickly!
I should probably wikify how to get these files compile: I first placed it in "tex/texmf-local" and ran "context --make" and "mtxrun --generate" didn't seem to do the trick for me. I also tried the same after placing the file in "tex/context/modules/mkxl" (where the "crappyspec" module resides), but although I get the "temp-new" module to load, I still get complaints about "missing number, treated as zero". Maybe the primitive is not correctly overloaded? Or (more likely) I'm not doing it right to get the mkxl file being executed. :-)
Regarding the formatting, maybe this could be constructed similarly to
\date[d=25,m=4,y=2008][weekday,month,day,{,~},year]
one could specify similarly to other parsers where "m" is reserved for "month" etc (obviously we could overload as they are associated with \date[] and not with \time[]).
H= % hours as decimal number (0–24)
I= % hours as decimal number (0–12) [not sure if needed]
M= % minute as decimal number (0–59)
S= % Seconds as decimal number (0–61)
p % (optional) AM/PM indicator in the locale; used in conjunction with I and not with H
u % (optional) unit for durations
so
\time[H=16,M=32][hour,{:},minute]
% 16:32
\time[H=16,M=32][hour,{:},minute,{ },indicator]
% 4:32 pm
and one could "hijack" the command for durations as well (with some overloading similar to "m", "MONTH", "mm", "month" etc.)
\time[M=3,S=30,u=minute][MM,{:},SS,{ },unit]
% 04:32 min
(Unit would take abbreviation from the units module, ideally.)
Then
\setuplangauge[en][time={HH, :, MM, :, p}]
Just a couple of thoughts though. Thank you for all your help!
Benjamin
> On Jun 10, 2025, at 05:45, Hans Hagen <j.hagen@xs4all.nl> wrote:
>
> On 6/10/2025 2:35 AM, Benjamin Buchmuller wrote:
>> Hi list,
>> I was wondering if there is a "\time" equivalent similar to "\currentdate" -> "\date"?
>> I know from the wiki (and source) that there is "\currenttime", but "\time[h=8, m=30]" will not typeset "8:30", so it doesn't seem to be implemented. I understand that such an implementation might become arbitrarily complicated …
>> In fact, I'm trying to typeset durations like "3:30 min" which is not exactly a "time" either, but neither \unit{3:30 minute} nor a math formula achieve the expected rendering. Of course, one could just type it plainly, but maybe this little gap is worthwhile considering in a future version. :-)
>
> It's no problem to add something and it's kind of trivial to implement anyway. See attached.
>
> You need to keep in mind that \time is also a primitive (do users actually use that one?) so we need to remain compatible with its usage as number, think:
>
> \time1234 % sets the time
>
> \time[] % typesets the time
>
> \the\time % typesets the number
>
> intercepting h and m also has to involve overflow
>
> how about seconds? and pm/am ?
>
> you can test the attached proof of concept and contemplate the above (and do some research in language dependencies) .. when i got enough input we can (after wolfgangs quality assurance check) add something to the core (in order to keep the format small i can then kick out something unused)
>
> 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
> -----------------------------------------------------------------<temp-new.mkxl>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
next parent reply other threads:[~2025-06-10 16:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E13C3B74-B32D-4261-8727-7DE2FBAE3FC8@gmail.com>
[not found] ` <8390cdfc-cc73-4a8a-9e27-ca5ce12ea278@xs4all.nl>
2025-06-10 16:54 ` Benjamin Buchmuller [this message]
2025-06-10 21:27 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4196426B-E2D2-4FB8-8B8D-91AF9F73D2B7@gmail.com \
--to=benjamin.buchmuller@gmail.com \
--cc=j.hagen@xs4all.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).