Skip to content

Duration

javarome edited this page Nov 1, 2024 · 2 revisions

A duration is a special type of component whose value has less restricted bounds;

classDiagram
    class DateComponent {
        value: number
        unit: Unit
    }
    class Duration {
        toString(): string
        toSpec()
        fromString(str)$: Duration
        between(dateStart, dateEnd)$: Duration
    }
    DateComponent <|-- Duration
Loading

Parsing

You can select the API level you want to use. For example using level 0:

import {Level2Duration as Duration} from "@rr0/time"

const aroundTenMinutes = Duration.fromString("P10M~")
aroundTenMinutes.value            // 10 * GregorianCalendar.minute.duration
aroundTenMinutes.toSpec().minutes // 10
Clone this wiki locally