mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
5415095ef3
commit
4c99d6c8b3
@ -45,6 +45,28 @@ use crate::World;
|
|||||||
/// )
|
/// )
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// # Datetime and Duration
|
||||||
|
/// You can get a [duration] by subtracting two datetime:
|
||||||
|
/// ```example
|
||||||
|
/// #let first-of-march = datetime(day: 1, month: 3, year: 2024)
|
||||||
|
/// #let first-of-jan = datetime(day: 1, month: 1, year: 2024)
|
||||||
|
/// #let distance = first-of-march - first-of-jan
|
||||||
|
/// #distance.hours()
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// You can also add/subtract a datetime and a duration to retrieve a new,
|
||||||
|
/// offset datetime:
|
||||||
|
/// ```example
|
||||||
|
/// #let date = datetime(day: 1, month: 3, year: 2024)
|
||||||
|
/// #let two-days = duration(days: 2)
|
||||||
|
/// #let two-days-earlier = date - two-days
|
||||||
|
/// #let two-days-later = date + two-days
|
||||||
|
///
|
||||||
|
/// #date.display() \
|
||||||
|
/// #two-days-earlier.display() \
|
||||||
|
/// #two-days-later.display()
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// # Format
|
/// # Format
|
||||||
/// You can specify a customized formatting using the
|
/// You can specify a customized formatting using the
|
||||||
/// [`display`]($datetime.display) method. The format of a datetime is
|
/// [`display`]($datetime.display) method. The format of a datetime is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user