The zyt1 package translates month and day names from Go's time package to and from non-English languages.
When parsing multiple name variants are understood. For example the month
January in German is recognized as
Januar
, Jänner
and multiple
abbreviations.
Languages using partitive and genitive cases for months and days are supported (e.g. Finnish and many Slavic languages).
Locales can be customized by users, either by defining from scratch or by cloning and modifying.
To print the current time in German:
fmt.Println(zyt.German.Format(time.RFC850, time.Now()))
To parse a timestamp in Finnish:
fmt.Println(zyt.Finnish.ParseInLocation("January 2006", "maaliskuu 2001", time.UTC))
To select the best-fitting locale:
l, _ := zyt.Best(language.BritishEnglish)
l.Format(time.RFC850, time.Now())
- English
- German
- Austrian German
- Finnish
Contributions to add more are very welcome.
- github.com/goodsign/monday, an older package only supporting one variant per name.
Footnotes
-
Zyt is Swiss German for time. ↩