-
Notifications
You must be signed in to change notification settings - Fork 4
/
time.pest
24 lines (21 loc) · 1.13 KB
/
time.pest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
weekday = { "monday" | "mon" | "tuesday" | "tue" | "wednesday" | "wed" | "thursday" | "thu" | "friday" | "fri" | "saturday" | "sat" | "sunday" | "sun" }
now = { "now" }
am_or_pm = { "am" | "pm"}
modifier = { "last" | "next" }
quantifier = { "min" | "hours" | "hour" | "h" | "days" | "day" | "d" | "weeks" | "week" | "w" | "months" | "month" }
shortcut_day = { "today" | "yesterday" | "tomorrow" }
mday = ${ (modifier)? ~ WHITE_SPACE* ~ weekday | shortcut_day }
relative = ${ int ~ WHITE_SPACE* ~ quantifier ~ WHITE_SPACE* ~ "ago"}
relative_future = ${ "in" ~ WHITE_SPACE* ~ int ~ WHITE_SPACE* ~ quantifier }
time = ${ hms ~ (":" ~ hms)? ~ (":" ~ hms)? ~ WHITE_SPACE* ~ am_or_pm?}
day_at = ${ mday ~ WHITE_SPACE* ~ ("at" ~ WHITE_SPACE* ~ time)?}
iso = ${ year ~ "-" ~ month ~ "-" ~ day ~ "T" ~ hms ~ (":" ~ hms)? ~ (":" ~ hms)? }
date = ${ day ~ date_sep ~ month ~ date_sep ~ year }
date_sep = _{ "/" | "-" }
time_clue = {SOI ~ (now | iso | date | relative | relative_future | time | day_at) ~ EOI }
hms = { ASCII_DIGIT{1,2} }
year = { ASCII_DIGIT{4} }
month = { ASCII_DIGIT{2} }
day = { ASCII_DIGIT{2} }
int = { ASCII_DIGIT+ }
WHITESPACE = _{ " " }