From 752817ae74607ca23ec0aad51824ddca66faa7a8 Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> Date: Tue, 23 May 2023 10:41:20 +0200 Subject: Add support for date & time handling (#435) --- tests/src/benches.rs | 6 +++++- tests/src/tests.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/src') diff --git a/tests/src/benches.rs b/tests/src/benches.rs index 9e9b98d0..aeddcaf9 100644 --- a/tests/src/benches.rs +++ b/tests/src/benches.rs @@ -3,7 +3,7 @@ use std::path::Path; use comemo::{Prehashed, Track, Tracked}; use iai::{black_box, main, Iai}; use typst::diag::{FileError, FileResult}; -use typst::eval::Library; +use typst::eval::{Datetime, Library}; use typst::font::{Font, FontBook}; use typst::geom::Color; use typst::syntax::{Source, SourceId}; @@ -147,4 +147,8 @@ impl World for BenchWorld { fn file(&self, path: &Path) -> FileResult { Err(FileError::NotFound(path.into())) } + + fn today(&self, _: Option) -> Option { + Some(Datetime::from_ymd(1970, 1, 1).unwrap()) + } } diff --git a/tests/src/tests.rs b/tests/src/tests.rs index f295869f..c2d0cc68 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -22,7 +22,7 @@ use walkdir::WalkDir; use typst::diag::{bail, FileError, FileResult}; use typst::doc::{Document, Frame, FrameItem, Meta}; -use typst::eval::{func, Library, Value}; +use typst::eval::{func, Datetime, Library, Value}; use typst::font::{Font, FontBook}; use typst::geom::{Abs, Color, RgbaColor, Sides, Smart}; use typst::syntax::{Source, SourceId, Span, SyntaxNode}; @@ -296,6 +296,10 @@ impl World for TestWorld { .get_or_init(|| read(path).map(Buffer::from)) .clone() } + + fn today(&self, _: Option) -> Option { + Some(Datetime::from_ymd(1970, 1, 1).unwrap()) + } } impl TestWorld { -- cgit v1.2.3