Repository navigation
Accept Duration type timezone offset values - #7691
Conversation
02e1c25 to
176ce26
Compare
Add support for offset handling in the test-runner implementation of World::today(). Add some checks for offsets with forward/backward day wrapping.
Preparation step to support timezone offset values in `#datetime.today()` that are not full hours.
Support timezone offset values in `#datetime.today()` which are not full hours. For example this applies to the Newfoundland Time Zone (UTC-03:30/ UTC-02:30), or Nepal Standard Time (UTC+05:45). Fixes typst#6277.
176ce26 to
610f541
Compare
Duration type timezone offset values
| #test(datetime.today(offset: 24).display(), "1970-01-02") | ||
| #test(datetime.today(offset: -24).display(), "1969-12-31") | ||
| #test(datetime.today(offset: duration(hours: 5, minutes: 45)).display(), "1970-01-01") | ||
| #test(datetime.today(offset: duration(days: 2)).display(), "1970-01-03") | ||
| #test(datetime.today(offset: duration(days: -2)).display(), "1969-12-30") |
There was a problem hiding this comment.
These tests are a tad misleading because the actual CLI function using FixedOffset does not allow a duration >= 24h. Perhaps, we should rather base the TestWorld's today output on a time different than midnight such that an offset < 24h can have an effect in both directions.
I also noticed #7843 while playing with this. I'm good with merging the fix as-is for now, but aligning the CLI and test impls a bit more could be a good followup.
There was a problem hiding this comment.
Thanks for bringing the limitation with FixedOffset to my attention, I somehow missed that.
I assume aligning CLI and test World impls would mean the offset calculation is also done with chrono types in the tests?
There was a problem hiding this comment.
That would be an option. Alternatively, we could impose the limitation separately in the tests though at that point we're not testing all that much I suppose.
I could also imagine moving the chrono based today impl to typst-kit to share it, but that would be a slightly larger task and might involve some API design bikeshedding. And it would need to support both current and fixed time of course.
While looking at that, I just noticed that we're depending on Local timezone even when SOURCE_DATE_EPOCH is set, which I guess is not great for reproducibility.
But anyways, I'm going a bit off-topic. There are more things to improve here, but moving the tests to a reproducible chrono based impl would be a reasonable first step I think.
|
Thanks! |
Create date values in tests with a chrono-based approach that is similar to the implementation in `typst-cli`. Suggested in typst#7691.
Create date values in tests with a chrono-based approach that is similar to the implementation in `typst-cli`. Suggested in typst#7691.
Only apply the local timezone offset in the CLI implementation of `World::today()` when no fixed date is used, and no offset argument is set. Mentioned by Laurenz in typst#7691.
Always use UTC timezone in the CLI implementation of `World::today()` when a fixed date is requested. Only apply the local timezone offset when the date is not fixed, and no offset argument is set. Mentioned in typst#7691.
Co-authored-by: Laurenz <[email protected]>
commit 65301b2 Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Fri Jun 5 00:57:12 2026 +0000 build: update tinymist to 0.14.23 commit 3ac7c69 Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Thu Jun 4 23:30:34 2026 +0000 build: update tinymist to 0.14.23-rc1 commit 4f5efbf Author: paran3xus <[email protected]> Date: Thu Jun 4 12:41:19 2026 +0000 feat: add compatibility for typst/typst#7865 and typst/typst#8116 commit cb25b2e Author: paran3xus <[email protected]> Date: Sat May 16 10:06:29 2026 +0000 fix: adapt typstyle-consistency to typst/typst#7964 commit ae25cb3 Author: paran3xus <[email protected]> Date: Sat May 16 10:06:22 2026 +0000 fix: adapt today to typst/typst#7691 commit c5702de Author: paran3xus <[email protected]> Date: Sat May 16 05:14:33 2026 +0000 build: patch typst-bundle commit aeffa37 Author: paran3xus <[email protected]> Date: Fri May 15 05:09:16 2026 +0000 build: bump tinymist-world to nightly (remote branch) commit 8ea80b1 Author: paran3xus <[email protected]> Date: Thu May 14 05:08:26 2026 +0000 build: bump typst to nightly (local patch) a
This PR is part of the Typst 0.15 cleanup stack. It sits on top of the dependency/toolchain group and covers the first world/document output API adaptation slice. ## Upstream Typst Changes - [`typst/typst#7964` Bundle export](typst/typst#7964) splits document output into target-specific APIs. - Tinymist now works with `typst_layout::PagedDocument`, `typst_html::HtmlDocument`, `typst::model::Document`, and `typst::foundations::Output` instead of relying on the old broad document surface. - Document fields are private; callers need accessors such as `pages()`, `info()`, `introspector()`, and `root_mut()`. - Document introspection changes around `typst/typst@7d2edbdb3` move consumers toward the target document's output introspector. - `DocumentInfo` is the compiled-document metadata payload (`title`, `author`, `description`, `keywords`, `date`, `locale`). Typst populates it while creating the target document from document/text styles, not from finished `Page` or `Frame` values. - HTML/SVG conversion now goes through the bundle-aware `svg_in_html` path with a `LateLinkResolver`. - [`typst/typst#7691`](typst/typst#7691) changes `World::today` from an hour offset to `Option<typst::foundations::Duration>`. - `typst/typst@acc3fed51` moves paged positions to `typst::introspection::PagedPosition`. - Typst 0.15 also requires protected engine introspection through `typst::utils::Protected`. ## Tinymist Changes - Adapts `tinymist-std`, `tinymist-world`, and `tinymist-task` to the new `Document` / `Output` split and concrete paged/HTML document types. - Updates query export for the new `eval_string` signature and uses `SpanMode::Uniform(Span::detached())` for selector strings that do not come from a `.typ` source range. - Updates paged document access, output introspector access, debug location typing, preview/outline consumers, and HTML root mutation to the new accessor-based APIs. - Preserves original compiled document metadata for merged PNG/SVG exports with `doc.info().clone()` while still constructing a temporary document from selected pages. - Updates typlite SVG embedding to forward real `HtmlFrame` metadata when available and use neutral standalone-frame defaults when only a bare `Frame` is available. - Updates `World::today` for Typst duration offsets while keeping existing cached `now` initialization in place; only the duration-to-second offset conversion is factored out. - Refreshes the minimal `Cargo.lock` metadata needed by the new `typst-layout` dependency path. --------- Co-authored-by: paran3xus <[email protected]>
This PR is part of the Typst 0.15 cleanup stack. It sits on top of the dependency/toolchain group and covers the first world/document output API adaptation slice. - [`typst/typst#7964` Bundle export](typst/typst#7964) splits document output into target-specific APIs. - Tinymist now works with `typst_layout::PagedDocument`, `typst_html::HtmlDocument`, `typst::model::Document`, and `typst::foundations::Output` instead of relying on the old broad document surface. - Document fields are private; callers need accessors such as `pages()`, `info()`, `introspector()`, and `root_mut()`. - Document introspection changes around `typst/typst@7d2edbdb3` move consumers toward the target document's output introspector. - `DocumentInfo` is the compiled-document metadata payload (`title`, `author`, `description`, `keywords`, `date`, `locale`). Typst populates it while creating the target document from document/text styles, not from finished `Page` or `Frame` values. - HTML/SVG conversion now goes through the bundle-aware `svg_in_html` path with a `LateLinkResolver`. - [`typst/typst#7691`](typst/typst#7691) changes `World::today` from an hour offset to `Option<typst::foundations::Duration>`. - `typst/typst@acc3fed51` moves paged positions to `typst::introspection::PagedPosition`. - Typst 0.15 also requires protected engine introspection through `typst::utils::Protected`. - Adapts `tinymist-std`, `tinymist-world`, and `tinymist-task` to the new `Document` / `Output` split and concrete paged/HTML document types. - Updates query export for the new `eval_string` signature and uses `SpanMode::Uniform(Span::detached())` for selector strings that do not come from a `.typ` source range. - Updates paged document access, output introspector access, debug location typing, preview/outline consumers, and HTML root mutation to the new accessor-based APIs. - Preserves original compiled document metadata for merged PNG/SVG exports with `doc.info().clone()` while still constructing a temporary document from selected pages. - Updates typlite SVG embedding to forward real `HtmlFrame` metadata when available and use neutral standalone-frame defaults when only a bare `Frame` is available. - Updates `World::today` for Typst duration offsets while keeping existing cached `now` initialization in place; only the duration-to-second offset conversion is factored out. - Refreshes the minimal `Cargo.lock` metadata needed by the new `typst-layout` dependency path. --------- Co-authored-by: paran3xus <[email protected]>
This PR is part of the Typst 0.15 cleanup stack. It sits on top of the dependency/toolchain group and covers the first world/document output API adaptation slice. - [`typst/typst#7964` Bundle export](typst/typst#7964) splits document output into target-specific APIs. - Tinymist now works with `typst_layout::PagedDocument`, `typst_html::HtmlDocument`, `typst::model::Document`, and `typst::foundations::Output` instead of relying on the old broad document surface. - Document fields are private; callers need accessors such as `pages()`, `info()`, `introspector()`, and `root_mut()`. - Document introspection changes around `typst/typst@7d2edbdb3` move consumers toward the target document's output introspector. - `DocumentInfo` is the compiled-document metadata payload (`title`, `author`, `description`, `keywords`, `date`, `locale`). Typst populates it while creating the target document from document/text styles, not from finished `Page` or `Frame` values. - HTML/SVG conversion now goes through the bundle-aware `svg_in_html` path with a `LateLinkResolver`. - [`typst/typst#7691`](typst/typst#7691) changes `World::today` from an hour offset to `Option<typst::foundations::Duration>`. - `typst/typst@acc3fed51` moves paged positions to `typst::introspection::PagedPosition`. - Typst 0.15 also requires protected engine introspection through `typst::utils::Protected`. - Adapts `tinymist-std`, `tinymist-world`, and `tinymist-task` to the new `Document` / `Output` split and concrete paged/HTML document types. - Updates query export for the new `eval_string` signature and uses `SpanMode::Uniform(Span::detached())` for selector strings that do not come from a `.typ` source range. - Updates paged document access, output introspector access, debug location typing, preview/outline consumers, and HTML root mutation to the new accessor-based APIs. - Preserves original compiled document metadata for merged PNG/SVG exports with `doc.info().clone()` while still constructing a temporary document from selected pages. - Updates typlite SVG embedding to forward real `HtmlFrame` metadata when available and use neutral standalone-frame defaults when only a bare `Frame` is available. - Updates `World::today` for Typst duration offsets while keeping existing cached `now` initialization in place; only the duration-to-second offset conversion is factored out. - Refreshes the minimal `Cargo.lock` metadata needed by the new `typst-layout` dependency path. --------- Co-authored-by: paran3xus <[email protected]>
Co-authored-by: Laurenz <[email protected]>
Support timezone offset values in
#datetime.today()which are not full hours. For example this applies to the Newfoundland Time Zone (UTC-03:30 / UTC-02:30), or Nepal Standard Time (UTC+05:45).Fixes #6277.