mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

V0.4 Fixing daylight saving problems #182

Closed sruetzler closed 7 years ago

sruetzler commented 7 years ago

timezone.js doesn't handle daylight saving switches correct. It stores the time as local time which isn't unique during daylight saving switch. This changes fixes the problem and makes the interface more compatible to the original Date object.

This is a test example which doesn't work with the original module: var date = new timezoneJS(2017,9,29,2,1,0,"Europe/Berlin"); var oldTime = date.getTime(); console.log(date.getTime()); console.log(date); console.log(date.getUTCHours(), date.getUTCMinutes(), date.getTimezoneOffset()); console.log(date.getHours()); date.setUTCMinutes(date.getUTCMinutes() + 60); console.log(date); console.log(date.getUTCHours(), date.getUTCMinutes(), date.getTimezoneOffset()); console.log(date.getHours()); console.log((date.getTime() - oldTime)/1000/60);

mde commented 7 years ago

All work on this library should probably be stopped in favor of eventually just using the upcoming native temporal module: https://github.com/maggiepint/proposal-temporal