Skip to content

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
Loading

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
Loading
Clone this wiki locally