Date Calculator

Dec 30, 2021

Syntax

Date calculator syntax in BNF grammar format.

<program> ::= (<dateExpr> | <durationExpr> <castExpr>*)

<dateExpr> ::= <date>
    | <date> (<plus> | <minus>) <durationExpr>

<durationExpr> ::= <duration>
    | <duration> (<plus> | <minus>) <durationExpr>
    | <date> <minus> <dateExpr>

<date> ::= ("now" | "today" | <number> "/" <number> "/" <number>)

<duration> ::= <number> <optWs> <unit>

<castExpr> ::= <ws> ("as" | "to") <ws> <unit>

<unit> ::= ("millisecond" | "second" | "minute" | "hour"
    | "day" | "week" | "month" | "year")

<number> ::= [0-9]+
<plus> ::= <optWs> "+" <optWs>
<minus> ::= <optWs> "-" <optWs>

<ws> ::= " "+
<optWs> ::= " "*

Updates

1/25/2024

12/27/2023

10/19/2023