0

is this valid to get offset from abbreviation like IST etc.?

Code
  • 1,574
  • 2
  • 23
  • 37

1 Answers1

2

Is this valid to get offset from abbreviation like IST?

I wouldn't say "valid", but "innacurate".

Abbreviations like IST are ambiguous. IST is used in India, Israel and Ireland, each one with a different offset.

Not only that, but each timezone is actually a list of offsets during history (past, present and future). Even though India uses +05:30 today, in the 40's there were lots of changes: in some periods, the offset was +06:30, so depending on where and when you ask, you might get a different offset.

So, to get the offset, you need 2 things:

  • the actual, non-ambiguous timezone name, as defined by IANA, such as Asia/Kolkata
  • a reference date, to get the offset that was used in that timezone, at that specific moment

You can use moment.tz's utcOffset method to get the offset from a specific timezone, at a specific instant.

PS: even names like "US Eastern Standard Time" are not a good thing to use, because this is a very comprehensive concept: EST covers lots of different places (hence, more than one IANA's timezone, and during DST it changes to EDT (Eastern Daylight Time). But some places don't have DST and use EST the whole year. The only way to solve this mess is to use a proper IANA's timezone identifier (such as America/New_York).

well
  • 85
  • 4