module Timing grammar NaturalTimeLanguage rule expression space* moment:moment space* zone_offset:zone_offset? space* end rule moment timestamp / time_ago / moment_at_time / before_from_moment / date_moment end rule date_moment named_moment / last_next_day_name / day_month_name_year / year_month_day / beginning_end_interval end rule named_moment now / today / tomorrow / yesterday end rule last_next_day_name direction:last_next space* day_name:day_name end rule day_month_name_year day:integer space* month:month_name space* year:integer? space* end rule year_month_day year:integer '-' month:integer '-' day:integer end rule beginning_end_interval direction:beginning_end space* interval_type:interval end rule time_ago number:integer space* interval_type:interval space* 'ago'i end rule moment_at_time moment:date_moment space* 'at'i space* time:hour_minute_second end rule before_from_moment number:integer space* interval_type:interval space* direction:before_from space* moment:moment end rule timestamp [\d]4..4 '-' [\d]2..2 '-' [\d]2..2 space* 'T'? space* [\d]2..2 ':' [\d]2..2 ':' [\d]2..2 end rule now 'now'i end rule today 'today'i end rule tomorrow 'tomorrow'i end rule yesterday 'yesterday'i end rule last_next last / next end rule last 'last'i end rule next 'next'i end rule beginning_end beginning_of / end_of end rule beginning_of direction:'beginning'i space* 'of'i end rule end_of direction:'end'i space* 'of'i end rule before_from before / from end rule before 'before'i end rule from 'from'i end rule interval second_interval / minute_interval / hour_interval / day_interval / week_interval / month_interval / year_interval end rule second_interval 'second'i 's'i? end rule minute_interval 'minute'i 's'i? end rule hour_interval 'hour'i 's'i? end rule day_interval 'day'i 's'i? end rule week_interval 'week'i 's'i? end rule month_interval 'month'i 's'i? end rule year_interval 'year'i 's'i? end rule day_name long_day_name / short_day_name end rule long_day_name 'sunday'i / 'monday'i / 'tuesday'i / 'wednesday'i / 'thursday'i / 'friday'i / 'saturday'i end rule short_day_name 'sun'i / 'mon'i / 'tue'i / 'wed'i / 'thu'i / 'fri'i / 'sat'i end rule month_name long_month_name / short_month_name end rule long_month_name 'january'i / 'february'i / 'march'i / 'april'i / 'may'i / 'june'i / 'july'i / 'august'i / 'september'i / 'october'i / 'november'i / 'december'i end rule short_month_name 'jan'i / 'feb'i / 'mar'i / 'apr'i / 'may'i / 'jun'i / 'jul'i / 'aug'i / 'sep'i / 'oct'i / 'nov'i / 'dec'i end rule zone_offset [+-] [\d]2..2 ':'? [\d]2..2 end rule hour_minute_second [\d]2..2 ':' [\d]2..2 (':' [\d]2..2)? / 'beginning' / 'end' end rule integer [\d]+ end rule space [\s\t\n] end end end