From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@xs4all.nl>, Pablo Rodriguez <oinos@gmx.es>
Subject: Re: setting date in \setupinteraction
Date: Wed, 20 Oct 2021 16:02:20 +0200 [thread overview]
Message-ID: <70256278-0d52-9ade-9d23-ac9e2f8f5c24@xs4all.nl> (raw)
In-Reply-To: <CF3O98HZ9KYZ.P00VVCZPU75N@deimos>
On 10/19/2021 10:38 PM, Michal Vlasák via ntg-context wrote:
> I don't know how official these interfaces are. But you can try adapting
> the following to your use case.
>
> \setupinteraction[state=start]
>
> %\luacode{lpdf.settime("2020-02-02 12:00")}
> %\luacode{lpdf.settime(1580641221)}
>
> \startluacode
>
> local Y, M, D, h, m, s, Zs, Zh, Zm = string.match("D:20200202120021+02'00'", "^D:(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)([%+%-])(%d%d)%'(%d%d)%'$")
>
> local time = os.time{year=Y,month=M,day=D,hour=h,min=m,sec=s}
> lpdf.settime(time)
> \stopluacode
>
> \starttext
> This document is from 02.02.2020 at 12:00:21.
> \stoptext
>
> The pattern doesn't catch all the PDF spec cases, but should match what
> ConTeXt emits. The timezone info gets overwritten by current timezone
> though.
>
> Requires the below patch.
>
> Michal
>
> --- a/tex/context/base/mkiv/core-con.lua
> +++ b/tex/context/base/mkiv/core-con.lua
> @@ -1991,7 +1991,7 @@ function converters.totime(s)
> end
> local n = tonumber(s)
> if n and n >= 0 then
> - return date("*t",n)
> + return osdate("*t",n)
> end
> end
>
> diff --git a/tex/context/base/mkxl/lpdf-ini.lmt b/tex/context/base/mkxl/lpdf-ini.lmt
> index 7979b80..9703ac0 100644
> --- a/tex/context/base/mkxl/lpdf-ini.lmt
> +++ b/tex/context/base/mkxl/lpdf-ini.lmt
> @@ -1123,7 +1123,7 @@ do
> n = converters.totime(n)
> if n then
> converters.settime(n)
> - timestamp = osdate("%Y-%m-%dT%X") .. ostimezone(true) -- probably not ok
> + timestamp = osdate("%Y-%m-%dT%X", ostime(n)) .. ostimezone(true) -- probably not ok
> end
> end
> if metadata then
i'll fix it but also clean up the existing code a bit
(much has to do with omitting date and is for comparison reasons)
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
___________________________________________________________________________________
next prev parent reply other threads:[~2021-10-20 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 15:47 Pablo Rodriguez via ntg-context
2021-10-19 16:23 ` Michal Vlasák via ntg-context
2021-10-19 18:51 ` Pablo Rodriguez via ntg-context
2021-10-19 20:38 ` Michal Vlasák via ntg-context
2021-10-20 14:02 ` Hans Hagen via ntg-context [this message]
2021-10-21 16:38 ` Pablo Rodriguez via ntg-context
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=70256278-0d52-9ade-9d23-ac9e2f8f5c24@xs4all.nl \
--to=ntg-context@ntg.nl \
--cc=j.hagen@xs4all.nl \
--cc=oinos@gmx.es \
/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).