-
Notifications
You must be signed in to change notification settings - Fork 0
DateComponent
javarome edited this page Nov 1, 2024
·
2 revisions
A date component is a value
with a unit
, which allows only valid values.
classDiagram
class Validator {
name: string
validate(value: number): boolean
}
class DateComponent {
value: number
}
DateComponent --> Unit: unit
class Unit {
name: string
min: number
max: number
duration(): number
}
Unit --> Unit: subUnit
Unit --> Validator: validator
Each specialization of DateComponent:
- can parse a different format
- is validated by a specific validator.
classDiagram
class DateComponent {
}
class Year {
fromString(str)$: Year
}
DateComponent <|-- Year
class Month {
fromString(str)$: Month
}
DateComponent <|-- Month
class Day {
fromString(str)$: Day
}
DateComponent <|-- Day
class Hour {
fromString(str)$: Hour
}
DateComponent <|-- Hour
class Minute {
fromString(str)$: Minute
}
DateComponent <|-- Minute
class Second {
fromString(str)$: Second
}
DateComponent <|-- Second
Each date calendar (year, month, day) and time (hour, minute, second) component can also be individually instantiated.
import { Level2Year as EdtfYear } from "@rr0/time/level2/year/index.mjs"
const inTheFifities = EdtfYear.fromString("195X")
Each date calendar and time component can be individually instantiated.
import { Level2Year as EdtfYear } from "@rr0/time/level2/year/index.mjs"
const someYear = new EdtfYear(1985)
someYear.value // "1985"
const currentYear = EdtfYear.newInstance()
someYear.value // Displays current year