This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |