Friday, 16 February 2018

Computer Science Internationalization - Time Zones

Yesterday, I wrote some code especially for the Chinese New Year 狗年. Look at the date in the last text box at jsfiddle.net/coas/zvubxato. I wanted to test that my code worked correctly for browsers in different time zones. I am in the UK so my time zone is currently GMT+0000. It is actually really easy to change time zone in OSX.

Go to System Preferences ➜ Date & Time ➜ Time Zone. Change of time zone is live and immediate. No need to close the time zone window nor restart your Mac. In the below screen shot I have selected Australian Eastern Daylight Time. Using JavaScript Date() I get the output Fri Feb 16 2018 22:05:34 GMT+1100 (AEDT) . This easy changing of time zones made testing of my code very easy and I did test my code with many different time zones. Why did I test with so many time zones? Well, because it was fun exploring time zones round the world😀 Did you know, for instance, that North Korea 조선민주주의인민공화국 and South Korea 대한민국 have different time zones. North Korea is currently GMT+0830 and South Korea is currently GMT+0900.

There are differences between browsers in how well they pick up the OSX timezone. Safari and Google Chrome behave best as whenever I change timezone and run my JavaScript Date() code the new timezone date is displayed. With Firefox, Opera and Yandex one has to either restart or open up a new browser window in order to get the new timezone date.

Environment: OSX High Sierra version 10.13.2