Ryouiki
Self-hosted domain communication service

Scheduler

Data Structure

Date {
    Year  :integer
    Month :range{1, 12}
    Day   :range{1, 31}
}

Time {
    Hour   :range{0, 23}
    Minute :range{0, 60}
    Second :range{0, 60}
    Zone   :integer
}

DateTime {
    Date :Date
    Time :Time
}

Sequence {
    Step   :natural
    Offset :integer
}

Pattern :: list{union {
    Values   :list{natural}
    Sequence :Sequence
}}

Constraint :: union {
    Offset   :Pattern
    Calendar :Pattern
}

DayConstraint :: union {
    Offset  :Pattern
    OfWeek  :Pattern
    OfMonth :Pattern
}

WeekConstraint :: union {
    Offset  :Pattern
    OfMonth :Pattern
    OfYear  :Pattern
}

Field :: union {
    Day    :DayConstraint
    Week   :WeekConstraint
    Month  :Constraint
    Year   :Constraint
    Hour   :Constraint
    Minute :Constraint
    Second :Constraint
}

Schedule {
    Constraints :list{Field}
    Nth :list{Sequence}

    Start :DateTime  # first possible Pattern
    End   :DateTime  # last possible Pattern
}

Timer :: union {
    Delay    :natural
    Schedule :Schedule
}