LocalTime

This is an idea for having internationalized and localized time expressions in Mediawiki. Currently it only covers relative time expressions, but we also have plans for absolute time expressions. Note, that we can already generate absolute time expressions (for example: 1. January 2011), but not parse them.

The syntax below is designed such that we can both generate and parse time expressions. Use cases would for example include giving durations of blocks. See also 19412

Syntax
The definition is a three level tree structure, currently given in a YAML format:


 * type of expression
 * magnitude
 * patterns

Type of expression can be:
 * 1) duration (ex: 5 days)
 * 2) how long something takes/has taken/will take
 * 3) interval-past (ex: yesterday, 6 weeks ago)
 * 4) how much time ago something happened
 * 5) duration-future (ex: after 2 hours)
 * 6) when something happens at earliest

Magnitude can be:
 * 1) seconds
 * 2) minutes
 * 3) hours
 * 4) days
 * 5) weeks
 * 6) months
 * 7) years
 * 8) decades
 * 9) centuries
 * 10) millennia

Patterns are of form.

Conditions are of form  and , where # is the number in the expression, which is compared against plain number N, or the index of convertPlural function if INDEX(#). INDEX(#) is same as 0 1s

Expressions are strings where # is replaced with a formatted number. When the number # can match multiple conditions, the first matching condition is used when generating expression. When parsing all expressions that match any condition are accepted.