Skip to content

truncate

In std/time.

fn truncate<U : TimeUnit>(self: Date, unit: Type<U>) : Date
fn truncate<U : TimeUnit>(self: DateTime, unit: Type<U>) : DateTime

The start of the unit containing self: the first day of the month for Month, the Monday of its ISO week for Week. A unit below Day leaves a Date unchanged.

fn truncate<U : TimeUnit>(self: Instant, unit: Type<U>) : Instant
fn truncate<U : TimeUnit>(self: Instant, unit: Type<U>, zone: Zone) : Instant

The start of the unit containing self, read in UTC, or in zone where one is given: Day in Zone("Europe/Berlin") is Berlin's midnight.