From aed087ba17716f1cee49d4c78010b8eabaeb90ea Mon Sep 17 00:00:00 2001 From: Abdulkader BENCHI Date: Thu, 22 Mar 2018 15:16:19 +0100 Subject: [PATCH] WIP: support timezone --- lib/angular-clockpicker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/angular-clockpicker.js b/lib/angular-clockpicker.js index d25ca72..8b82233 100644 --- a/lib/angular-clockpicker.js +++ b/lib/angular-clockpicker.js @@ -62,7 +62,8 @@ .value('clockpickerDefaultOptions', { twelvehour: true, autoclose: false, - donetext: 'ok' + donetext: 'ok', + local: false }) .directive('lngClockpicker', ['clockpickerService', 'clockpickerDefaultOptions', 'moment', '$timeout', 'detectUtils', function(clockpickerService, clockpickerDefaultOptions, moment, $timeout, detectUtils) { @@ -105,7 +106,8 @@ }); element.blur(function() { - ngModel.$valid && element.val(getModelValue().local().format(formatTime)); + var modalValue = options.local ? getModelValue().local() : getModelValue(); + ngModel.$valid && element.val(modalValue.format(formatTime)); }); ngModel.$render = function(val) { @@ -120,7 +122,7 @@ } var inUtc = getModelValue().isUTC(); var newDate = moment(getModelValue()); - newDate = newDate.local(); + newDate = options.local ? newDate.local() : newDate; newDate.hour(time.hour); newDate.minute(time.minute); newDate.second(0); @@ -134,7 +136,7 @@ return ''; } - var localMomentDate = momentDate.clone().local(); + var localMomentDate = options.local ? momentDate.clone().local() : momentDate.clone(); var isSameTime = !val || (val.hour === localMomentDate.hour() && val.minute === localMomentDate.minute());