Skip to content

Expose local timezone offset #7112

@LeanderBlume

Description

@LeanderBlume

Description

It would be useful to have a method datetime.localoffset() -> int, which returns the local offset to UTC. datetime.today(offset: auto) already uses this offset internally.

datetime.today(offset: datetime.localoffset()) should be equivalent to datetime.today(offset: auto), whatever type may be used in the future. See #6277.

This seems like a fairly small change that just exposes already existing internals. Ideally, there would be an API to access the whole timezone data base, but that might be too much.

Use Case

This would allow parsing dates given in UTC and displaying them in local time in a document, in a similar vein to #4107.

In my particular use case, I want to convert markdown files with a yaml metadata header to pdf using typst. The header contains date/time information given in UTC, which I want to display in the document in local time. Both pyrunner and jogs have issues with date/time access, so the only way to do this currently seems to be using --input arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestscriptingAbout Typst's coding capabilities

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions