提示:本教程存在过时问题,更详细教程请阅读 小蓝书Typst 中文社区导航 FAQ
注意:该中文文档为社区驱动的非官网文档,可能存在错译、漏译或过时等问题,请以官网文档 Documentation 为准,如发现错漏,也欢迎 您的贡献镜像)。Typst 非官方中文交流 QQ 群:793548390
Warning: the Chinese document is a community-driven non-official document, there may be mistranslation, omission or outdated problems, please refer to the official website documentation.
Typst 中文文档

duration

Represents a positive or negative span of time.

构造函数
如果类型具有构造函数,可以像函数一样调用它来创建一个该类型的值。

Creates a new duration.

You can specify the duration using weeks, days, hours, minutes and seconds. You can also get a duration by subtracting two datetimes.

#duration(
  days: 3,
  hours: 12,
).hours()
Preview

seconds
int

The number of seconds.

默认:0

minutes
int

The number of minutes.

默认:0

hours
int

The number of hours.

默认:0

days
int

The number of days.

默认:0

weeks
int

The number of weeks.

默认:0

定义
函数和类型可以有与其关联的定义 (成员或方法)。可以使用 "." 操作符来访问调用它们。

seconds

The duration expressed in seconds.

This function returns the total duration represented in seconds as a floating-point number rather than the second component of the duration.

self.seconds(
) -> float

minutes

The duration expressed in minutes.

This function returns the total duration represented in minutes as a floating-point number rather than the second component of the duration.

self.minutes(
) -> float

hours

The duration expressed in hours.

This function returns the total duration represented in hours as a floating-point number rather than the second component of the duration.

self.hours(
) -> float

days

The duration expressed in days.

This function returns the total duration represented in days as a floating-point number rather than the second component of the duration.

self.days(
) -> float

weeks

The duration expressed in weeks.

This function returns the total duration represented in weeks as a floating-point number rather than the second component of the duration.

self.weeks(
) -> float