Skip to content

Instantly share code, notes, and snippets.

View andrejtest-675's full-sized avatar

andrejtest-675

View GitHub Profile
// Also I know it's better to find some library for this task but if someone is okay with using a pure javascript solution, here's an example snippet. Please note timezone names are hard-coded but I don't expect the names change (the names, offset could change).
// It is a response to https://gist.github.com/redoPop/3915761
/*
It has 4 fallbacks,
1. first it tries to format the date as a string `${timezone}`,
and extract the timezone name from the braces at the end,
and look up the abbr in the dict,
2. then, if it's not in the dict, it just prints the part within ( and ),
3. if the date in text representation is not formatted with ( and ) at the end,