Skip to content

Addition of datetime and duration is not composable #7843

Closed

Description

@laurmaedje

Description

Adding a duration to a partial datetime that only consists of a date basically flattens the duration to day precision instead of turning the date into a datetime. I find this quite surprising:

#let some-day = datetime(year: 2000, month: 6, day: 5)
#let two-hours = duration(hours: 2)

#let val1 = some-day + 20 * two-hours

#let val2 = some-day
#for _ in range(20) {
  val2 += two-hours
}

// Equality assertion failed: value datetime(year: 2000, month: 6, day: 6) 
// was not equal to datetime(year: 2000, month: 6, day: 5)
#assert.eq(val1, val2)

Operating system

No response

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    scripting
    on Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscripting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions