Time parsing
lutfen includes a human date and time parser to simplify inputting dates and times that supports relative times, 24- and 1- hour time, and year-month-day and day-month-year dates.
The parser is used wherever the bot expects time input, e.g. when setting reminders.
Relative time
Relative times are specified as a number followed by a unit. The following units are supported:
Unit | Aliases | Equivalent |
---|---|---|
Second |
| – |
Minute |
| 60 seconds |
Hour |
| 3600 seconds |
Day |
| – |
Week |
| 7 days |
Month |
| 30 days |
Year |
| 365.2425 days |
You can use the plural of these units interchangeably with the singular form, add them by putting a space or plus between them, and subtract them by putting a minus before any number of them. You can use the word ago
at the very end to specify a time in the past.
Examples
Assume the current time is the noon of the 15th of June, 2050.
Example | Meaning |
---|---|
| 15th of June, 2049, 06:10:48 |
| 17th of June, 2050, 18:00:00 |
| 19th of June, 2050, noon |
| 19th of June, 2050, noon |
Absolute time
Absolute date-times are specified as a date followed by a time. The date can be in the year-month-day or day-month-year format. The time can be in the 24- or 12-hour format.
Year-month-day dates are split by hyphens (-
). Day-month-year dates are split by slashes (/
). Both periods (.
) and semicolons (:
) can be used to separate hours, minutes and seconds.
Date-time examples
Example | Meaning |
---|---|
| 15th of June, 2050, noon |
| 15th of June, 2050, noon |
| 15th of June, 2050, 6 hours past noon |
| 15th of June, 2050, 6 hours past noon |
Only specifying the date or time
Date and time are both optional, but one of them must be present. The next occurence of the time is assumed if the date is not present. Midnight of the day is assumed if the time is not present.
Example | Meaning |
---|---|
| Midnight between the 14th and 15th of June, 2050 |
| The next noon |
| The next midnight |
Timezones
The date, time, or date-time may be followed by a timezone. The timezone may be expressed as a UTC offset or a well-known timezone. The UTC
or GMT
keywords are used to specify a UTC offset, and they're equal.
Example | Meaning |
---|---|
| 7200 seconds ahead of UTC |
| 7260 seconds behind UTC |
Since well-known timezones are always changing, listing them here would be impractical. You can use the autocomplete feature of /custom timezone to find the timezone you want.
EBNF Grammar
If you understand grammars in Backus–Naur form, it may be useful for you to just read the grammar used by the parser.