From e160e3f3c527d86679d0645d9f1b5af7f2ee3a19 Mon Sep 17 00:00:00 2001 From: Chanuka Asanka Date: Sun, 13 Mar 2016 23:01:52 +0530 Subject: [PATCH] utcOffset for some timezone like xx:30, xx:45 issue has been fixed with utcOffset for some timezone like xx:30, xx:45 issue fixed with considering Minutes as well Time not showing correctly for GMT/UTC (3:30, 5:30, 5:45, 6:30, 8:30, 9:30 hours, if not XX:00) #261 https://github.com/g00fy-/angular-datepicker/issues/261 --- app/scripts/datePickerUtils.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/scripts/datePickerUtils.js b/app/scripts/datePickerUtils.js index 9925cbd..c5dc7dc 100644 --- a/app/scripts/datePickerUtils.js +++ b/app/scripts/datePickerUtils.js @@ -114,14 +114,16 @@ angular.module('datePicker').factory('datePickerUtils', function () { month = m.month(), day = m.date(), hours = [], - hour, pushedDate, actualOffset, - offset = m.utcOffset() / 60; - - for (hour = 0; hour < 24; hour++) { - pushedDate = createNewDate(year, month, day, hour - offset, 0, false); - actualOffset = pushedDate.utcOffset() / 60; - if (actualOffset !== offset) { - pushedDate = createNewDate(year, month, day, hour - actualOffset, 0, false); + hour, pushedDate, actualOffset, actualOffsetMinute, + offsetHour = Math.floor(m.utcOffset() / 60), + offsetMinute = m.utcOffset() % 60; + + for (hour = 0 ; hour < 24 ; hour++) { + pushedDate = createNewDate(year, month, day, hour - offsetHour, -offsetMinute, false); + actualOffset = Math.floor(pushedDate.utcOffset() / 60); + actualOffsetMinute = pushedDate.utcOffset() % 60; + if (actualOffset !== offsetHour && actualOffsetMinute !== offsetMinute) { + pushedDate = createNewDate(year, month, day, hour - actualOffset, -offsetMinute, false); } hours.push(pushedDate); }