choptastic/qdate_localtime

Error in handling of Asia/Tehran

Closed this issue · 3 comments

The entry for Tehran defines a DST name but not a DST weekday:

{"Asia/Tehran",{"IRST","IRST"},{"IRDT","IRDT"},210,60,undef,{0,0},undef,{0,0}},

This crashes the timezone conversion:

(z0x@PoToi)20> localtime:tz_name({{2008,12,10},{15,30,0}}, "Asia/Tehran").
** exception throw: {error,wrong_week_day}
     in function  localtime_dst:get_dst_day_of_year/2 (src/localtime_dst.erl, line 94)
     in call from localtime_dst:check/2 (src/localtime_dst.erl, line 30)
     in call from localtime:tz_name/2 (src/localtime.erl, line 136)

Is there a newer database with a corrected entry for Tehran or could we plug in a default date transition in this case?

/cc @mmzeeman who reported this issue first

Looking into this issue and recent Tz databases it is clear that due to Iran using their own calendar there is a problem with fixating the Tz definition here.

#	The official time of the country will should move forward one hour
#	at the 24[:00] hours of the first day of Farvardin and should return
#	to its previous state at the 24[:00] hours of the 30th day of
#	Shahrivar.

Which seems to turn out to be around March 22, and September 22. With some variations:

https://www.timeanddate.com/time/change/iran/tehran

We could use an approximation and hard-code that into the Erlang code, instead of relying on the Tz database here. Otherwise we need to add complete year-based calculations (which would be nice 😄 ).

Thanks again!

@choptastic Thanks Jesse for merging these changes!