Wednesday, February 26, 2020

Timezone bug in our code

PB corrected our schedule page code which was showing Australia NSW as GMT +10 instead of +11. Copy-pasting his solution - 

The countries which have DST spanning across the years have this issue. (Found 4 such countries) ...

I have set the dstStartMonth to January of this year as a temporary solution. ...

Modified the code to add the required condition 


FROM
if(($curMonth > $dstStartMonth && $curMonth < $dstEndMonth) ||
($curMonth == $dstStartMonth && $curDay >= $dstStartDay) ||
($curMonth == $dstEndMonth && $curDay <= $dstEndDay))
$offsetGmt= $offsetDst;
TO
if(($curMonth > $dstStartMonth && $curMonth < $dstEndMonth) ||
($curMonth < $dstStartMonth && $curMonth < $dstEndMonth &&  $dstStartMonth > $dstEndMonth) ||
($curMonth == $dstStartMonth && $curDay >= $dstStartDay) ||
($curMonth == $dstEndMonth && $curDay <= $dstEndDay))
$offsetGmt= $offsetDst;

Then restored the DST timings for the four countries.

No comments:

Post a Comment