momentjs - Why the UTC offsets available in moment-timezone are not exactly the same as Wikipedia UTC list -


i converting visitors local times utc using momentjs

visitor_utc = moment().utc().valueof() 

and getting offset

visitor_utc_offset = moment().utcoffset().valueof() / 60 

i have drop-down list filled offsets (... -01:00, +00:00, +01:00, +02:00 ....) user can change , set actual offset. default selected value visitor_utc_offset

is there method list of offsets using momentjs ?

with moment-timezone it's possible :

for element in moment.tz.names()     console.log moment.tz(element).format("z") 

but gives long list redundant values (because formatting timezones names can have same offset)

i found list in wikipedia list_of_utc_time_offsets not sure if it's complete list, , it's reliable future ?

update

to compare list of offsets used in moment-timezone , 1 wikipedia used code :

  element in moment.tz.names()     if $.inarray( moment.tz(element).format("z"), arr ) <= -1       arr.push moment.tz(element).format("z")  

which eliminate double entries, i've got array :

["+00:00", "+03:00", "+01:00", "+02:00", "-09:00", "-08:00", "-04:00", "-03:00", "-05:00", "-06:00", "-04:30", "-07:00", "-02:00", "-02:30", "+08:00", "+07:00", "+10:00", "+11:00", "+05:00", "+12:00", "+06:00", "+05:30", "+09:00", "+04:00", "+04:30", "+05:45", "+06:30", "-01:00", "+09:30", "+08:45", "+10:30", "-10:00", "-11:00", "-12:00", "+13:00", "+14:00", "+12:45", "-09:30", "+11:30"] 

this array contains 39 offsets, in wikipedia there 40 offsets

so after looking while able found in wikipedia can find offset +03:30 , -03:30 in moment-timezone can't !!

that's weird thing !?

recognize time zone not same offset.

time zones change offsets based on whims of governments. many change daylight saving time on regular, semi-regular, or irregular basis. have changed base-offsets other motivations, such when samoa jumped other side of international date line.

if ask current offset, not assured using correct offset given point in time. cannot pick point in time , assume offset the offset particular user.

with regard moment code, you're checking each time zone it's current offset. there history of offset changes represented each zone, not accounted in list. can examine offsets array within each zone entry see them.

see "time zone != offset" in the timezone tag wiki.

the valid use drop-down of offsets if creating date-time-offset picker. is, specific date , time associated specific offset. example, 1 might have form local date, time, , offset of specific event occurs.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -