From aef3380dea1ac588fb8ffcdfc81f8d3ee2ea4890 Mon Sep 17 00:00:00 2001 From: Flati Date: Wed, 7 Oct 2015 10:20:01 +0000 Subject: [PATCH 1/2] Fixed issue when decreasing to 0 hours in 24 hour format. Fixed an issue with step when going past the hour point (going from 55 to 05 with step 10 is now possible, does not force 0). Fixed an issue when inputEpoch was set to 0, now using 0 instead of last known value. --- bower.json | 2 +- dist/ionic-timepicker.bundle.min.js | 2 +- src/ionic-timepicker.directive.js | 33 +++++++---------------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/bower.json b/bower.json index a1b3766..a6024aa 100755 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ionic-timepicker", - "version": "0.3.0", + "version": "0.3.1", "authors": [ "rajeshwarpatlolla " ], diff --git a/dist/ionic-timepicker.bundle.min.js b/dist/ionic-timepicker.bundle.min.js index b4f4441..ec228de 100644 --- a/dist/ionic-timepicker.bundle.min.js +++ b/dist/ionic-timepicker.bundle.min.js @@ -1 +1 @@ -!function(t,e){var i=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(i),i.styleSheet)i.styleSheet.disabled||(i.styleSheet.cssText=e);else try{i.innerHTML=e}catch(n){i.innerText=e}}(document,"/* Empty. Add your own CSS if you like */\n\n.timePickerColon {\n padding-top: 40px;\n text-align: center;\n font-weight: bold;\n}\n\n.timePickerArrows {\n width: 100%;\n}\n\n.timePickerBoxText {\n text-align: center;\n border: 1px solid #dddddd !important;\n}\n\n.bar.bar-stable, .tabs {\n box-shadow: 0 0 5px #555;\n}\n\n.overflowShow {\n white-space: normal !important;\n}"),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-12-hour.html",'
')}])}(),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-24-hour.html",'
')}])}(),function(){"use strict";angular.module("ionic-timepicker",["ionic","ionic-timepicker.templates"])}(),function(){"use strict";function t(t){return{restrict:"AE",replace:!0,scope:{inputObj:"=inputObj"},link:function(e,i,n){console.log(e.inputObj);var o=new Date,s=o.getHours();e.inputEpochTime=e.inputObj.inputEpochTime?e.inputObj.inputEpochTime:60*s*60,e.step=e.inputObj.step?e.inputObj.step:15,e.format=e.inputObj.format?e.inputObj.format:24,e.titleLabel=e.inputObj.titleLabel?e.inputObj.titleLabel:"Time Picker",e.setLabel=e.inputObj.setLabel?e.inputObj.setLabel:"Set",e.closeLabel=e.inputObj.closeLabel?e.inputObj.closeLabel:"Close",e.setButtonType=e.inputObj.setButtonType?e.inputObj.setButtonType:"button-positive",e.closeButtonType=e.inputObj.closeButtonType?e.inputObj.closeButtonType:"button-stable";var u={epochTime:e.inputEpochTime,step:e.step,format:e.format};e.time={hours:0,minutes:0,meridian:""};var m=new Date(1e3*u.epochTime);e.increaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(12!=e.time.hours?e.time.hours+=1:e.time.hours=1),24==u.format&&(23!=e.time.hours?e.time.hours+=1:e.time.hours=0),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.decreaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(e.time.hours>1?e.time.hours-=1:e.time.hours=12),24==u.format&&(e.time.hours>0?e.time.hours-=1:e.time.hours=23),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.increaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes!=60-u.step&&e.time.minutes+u.step<=60?e.time.minutes+=u.step:e.time.minutes=0,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.decreaseMinutes=function(){e.time.minutes=Number(e.time.minutes),0!=e.time.minutes&&e.time.minutes-u.step>0?e.time.minutes-=u.step:e.time.minutes=60-u.step,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.changeMeridian=function(){e.time.meridian="AM"===e.time.meridian?"PM":"AM"},i.on("click",function(){e.inputObj.inputEpochTime&&(m=new Date(1e3*e.inputObj.inputEpochTime)),12==u.format?(e.time.meridian=m.getUTCHours()>=12?"PM":"AM",e.time.hours=m.getUTCHours()>12?m.getUTCHours()-12:m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,0==e.time.hours&&"AM"==e.time.meridian&&(e.time.hours=12),t.show({templateUrl:"ionic-timepicker-12-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=12!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,"AM"===e.time.meridian?i+=0:"PM"===e.time.meridian&&(i+=43200),e.etime=i,e.inputObj.callback(e.etime)}}]})):24==u.format&&(e.time.hours=m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,t.show({templateUrl:"ionic-timepicker-24-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=24!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,e.etime=i,e.inputObj.callback(e.etime)}}]}))})}}}angular.module("ionic-timepicker").directive("ionicTimepicker",t),t.$inject=["$ionicPopup"]}(); \ No newline at end of file +!function(t,e){var i=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(i),i.styleSheet)i.styleSheet.disabled||(i.styleSheet.cssText=e);else try{i.innerHTML=e}catch(n){i.innerText=e}}(document,"/* Empty. Add your own CSS if you like */\n\n.timePickerColon {\n padding-top: 40px;\n text-align: center;\n font-weight: bold;\n}\n\n.timePickerArrows {\n width: 100%;\n}\n\n.timePickerBoxText {\n text-align: center;\n border: 1px solid #dddddd !important;\n}\n\n.bar.bar-stable, .tabs {\n box-shadow: 0 0 5px #555;\n}\n\n.overflowShow {\n white-space: normal !important;\n}"),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-12-hour.html",'
')}])}(),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-24-hour.html",'
')}])}(),function(){"use strict";angular.module("ionic-timepicker",["ionic","ionic-timepicker.templates"])}(),function(){"use strict";function t(t){return{restrict:"AE",replace:!0,scope:{inputObj:"=inputObj"},link:function(e,i,n){var o=new Date,s=o.getHours();e.inputEpochTime=e.inputObj.inputEpochTime?e.inputObj.inputEpochTime:60*s*60,e.step=e.inputObj.step?e.inputObj.step:15,e.format=e.inputObj.format?e.inputObj.format:24,e.titleLabel=e.inputObj.titleLabel?e.inputObj.titleLabel:"Time Picker",e.setLabel=e.inputObj.setLabel?e.inputObj.setLabel:"Set",e.closeLabel=e.inputObj.closeLabel?e.inputObj.closeLabel:"Close",e.setButtonType=e.inputObj.setButtonType?e.inputObj.setButtonType:"button-positive",e.closeButtonType=e.inputObj.closeButtonType?e.inputObj.closeButtonType:"button-stable";var u={epochTime:e.inputEpochTime,step:e.step,format:e.format};e.time={hours:0,minutes:0,meridian:""};var m=new Date(1e3*u.epochTime);e.increaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(12!=e.time.hours?e.time.hours+=1:e.time.hours=1),24==u.format&&(e.time.hours=(e.time.hours+1)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.decreaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(e.time.hours>1?e.time.hours-=1:e.time.hours=12),24==u.format&&(e.time.hours=(e.time.hours+23)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.increaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+u.step)%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.decreaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+(60-u.step))%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.changeMeridian=function(){e.time.meridian="AM"===e.time.meridian?"PM":"AM"},i.on("click",function(){m=new Date(1e3*e.inputObj.inputEpochTime),12==u.format?(e.time.meridian=m.getUTCHours()>=12?"PM":"AM",e.time.hours=m.getUTCHours()>12?m.getUTCHours()-12:m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,0===e.time.hours&&"AM"===e.time.meridian&&(e.time.hours=12),t.show({templateUrl:"ionic-timepicker-12-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=12!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,"AM"===e.time.meridian?i+=0:"PM"===e.time.meridian&&(i+=43200),e.etime=i,e.inputObj.callback(e.etime)}}]})):24==u.format&&(e.time.hours=m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,t.show({templateUrl:"ionic-timepicker-24-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=24!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,e.etime=i,e.inputObj.callback(e.etime)}}]}))})}}}angular.module("ionic-timepicker").directive("ionicTimepicker",t),t.$inject=["$ionicPopup"]}(); \ No newline at end of file diff --git a/src/ionic-timepicker.directive.js b/src/ionic-timepicker.directive.js index 0d98a56..2538991 100644 --- a/src/ionic-timepicker.directive.js +++ b/src/ionic-timepicker.directive.js @@ -17,8 +17,6 @@ }, link: function (scope, element, attrs) { - console.log(scope.inputObj); - var today = new Date(); var currentEpoch = today.getHours(); @@ -47,11 +45,7 @@ } } if (obj.format == 24) { - if (scope.time.hours != 23) { - scope.time.hours += 1; - } else { - scope.time.hours = 0; - } + scope.time.hours = (scope.time.hours + 1) % 24; } scope.time.hours = (scope.time.hours < 10) ? ('0' + scope.time.hours) : scope.time.hours; }; @@ -66,11 +60,7 @@ } } if (obj.format == 24) { - if (scope.time.hours > 0) { - scope.time.hours -= 1; - } else { - scope.time.hours = 23; - } + scope.time.hours = (scope.time.hours + 23) % 24; } scope.time.hours = (scope.time.hours < 10) ? ('0' + scope.time.hours) : scope.time.hours; }; @@ -78,21 +68,16 @@ scope.increaseMinutes = function () { scope.time.minutes = Number(scope.time.minutes); - if (scope.time.minutes != (60 - obj.step) && (scope.time.minutes + obj.step <= 60)) { - scope.time.minutes += obj.step; - } else { - scope.time.minutes = 0; - } + scope.time.minutes = (scope.time.minutes + obj.step) % 60; + scope.time.minutes = (scope.time.minutes < 10) ? ('0' + scope.time.minutes) : scope.time.minutes; }; scope.decreaseMinutes = function () { scope.time.minutes = Number(scope.time.minutes); - if (scope.time.minutes !== 0 && (scope.time.minutes - obj.step >= 0)) { - scope.time.minutes -= obj.step; - } else { - scope.time.minutes = 60 - obj.step; - } + + scope.time.minutes = (scope.time.minutes + (60 - obj.step)) % 60; + scope.time.minutes = (scope.time.minutes < 10) ? ('0' + scope.time.minutes) : scope.time.minutes; }; @@ -101,9 +86,7 @@ }; element.on("click", function () { - if (scope.inputObj.inputEpochTime) { - objDate = new Date(scope.inputObj.inputEpochTime * 1000); - } + objDate = new Date(scope.inputObj.inputEpochTime * 1000); if (obj.format == 12) { From aaf1c8b7ab7a7f8d2cb27e4520c438dd63dec2ac Mon Sep 17 00:00:00 2001 From: Flati Date: Wed, 7 Oct 2015 10:31:35 +0000 Subject: [PATCH 2/2] inputEpochTime is now optional again. --- dist/ionic-timepicker.bundle.min.js | 2 +- src/ionic-timepicker.directive.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/ionic-timepicker.bundle.min.js b/dist/ionic-timepicker.bundle.min.js index ec228de..3d0c643 100644 --- a/dist/ionic-timepicker.bundle.min.js +++ b/dist/ionic-timepicker.bundle.min.js @@ -1 +1 @@ -!function(t,e){var i=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(i),i.styleSheet)i.styleSheet.disabled||(i.styleSheet.cssText=e);else try{i.innerHTML=e}catch(n){i.innerText=e}}(document,"/* Empty. Add your own CSS if you like */\n\n.timePickerColon {\n padding-top: 40px;\n text-align: center;\n font-weight: bold;\n}\n\n.timePickerArrows {\n width: 100%;\n}\n\n.timePickerBoxText {\n text-align: center;\n border: 1px solid #dddddd !important;\n}\n\n.bar.bar-stable, .tabs {\n box-shadow: 0 0 5px #555;\n}\n\n.overflowShow {\n white-space: normal !important;\n}"),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-12-hour.html",'
')}])}(),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-24-hour.html",'
')}])}(),function(){"use strict";angular.module("ionic-timepicker",["ionic","ionic-timepicker.templates"])}(),function(){"use strict";function t(t){return{restrict:"AE",replace:!0,scope:{inputObj:"=inputObj"},link:function(e,i,n){var o=new Date,s=o.getHours();e.inputEpochTime=e.inputObj.inputEpochTime?e.inputObj.inputEpochTime:60*s*60,e.step=e.inputObj.step?e.inputObj.step:15,e.format=e.inputObj.format?e.inputObj.format:24,e.titleLabel=e.inputObj.titleLabel?e.inputObj.titleLabel:"Time Picker",e.setLabel=e.inputObj.setLabel?e.inputObj.setLabel:"Set",e.closeLabel=e.inputObj.closeLabel?e.inputObj.closeLabel:"Close",e.setButtonType=e.inputObj.setButtonType?e.inputObj.setButtonType:"button-positive",e.closeButtonType=e.inputObj.closeButtonType?e.inputObj.closeButtonType:"button-stable";var u={epochTime:e.inputEpochTime,step:e.step,format:e.format};e.time={hours:0,minutes:0,meridian:""};var m=new Date(1e3*u.epochTime);e.increaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(12!=e.time.hours?e.time.hours+=1:e.time.hours=1),24==u.format&&(e.time.hours=(e.time.hours+1)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.decreaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(e.time.hours>1?e.time.hours-=1:e.time.hours=12),24==u.format&&(e.time.hours=(e.time.hours+23)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.increaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+u.step)%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.decreaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+(60-u.step))%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.changeMeridian=function(){e.time.meridian="AM"===e.time.meridian?"PM":"AM"},i.on("click",function(){m=new Date(1e3*e.inputObj.inputEpochTime),12==u.format?(e.time.meridian=m.getUTCHours()>=12?"PM":"AM",e.time.hours=m.getUTCHours()>12?m.getUTCHours()-12:m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,0===e.time.hours&&"AM"===e.time.meridian&&(e.time.hours=12),t.show({templateUrl:"ionic-timepicker-12-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=12!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,"AM"===e.time.meridian?i+=0:"PM"===e.time.meridian&&(i+=43200),e.etime=i,e.inputObj.callback(e.etime)}}]})):24==u.format&&(e.time.hours=m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,t.show({templateUrl:"ionic-timepicker-24-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=24!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,e.etime=i,e.inputObj.callback(e.etime)}}]}))})}}}angular.module("ionic-timepicker").directive("ionicTimepicker",t),t.$inject=["$ionicPopup"]}(); \ No newline at end of file +!function(t,e){var i=t.createElement("style");if(t.getElementsByTagName("head")[0].appendChild(i),i.styleSheet)i.styleSheet.disabled||(i.styleSheet.cssText=e);else try{i.innerHTML=e}catch(n){i.innerText=e}}(document,"/* Empty. Add your own CSS if you like */\n\n.timePickerColon {\n padding-top: 40px;\n text-align: center;\n font-weight: bold;\n}\n\n.timePickerArrows {\n width: 100%;\n}\n\n.timePickerBoxText {\n text-align: center;\n border: 1px solid #dddddd !important;\n}\n\n.bar.bar-stable, .tabs {\n box-shadow: 0 0 5px #555;\n}\n\n.overflowShow {\n white-space: normal !important;\n}"),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-12-hour.html",'
')}])}(),function(t){try{t=angular.module("ionic-timepicker.templates")}catch(e){t=angular.module("ionic-timepicker.templates",[])}t.run(["$templateCache",function(t){t.put("ionic-timepicker-24-hour.html",'
')}])}(),function(){"use strict";angular.module("ionic-timepicker",["ionic","ionic-timepicker.templates"])}(),function(){"use strict";function t(t){return{restrict:"AE",replace:!0,scope:{inputObj:"=inputObj"},link:function(e,i,n){var o=new Date,s=o.getHours();e.inputEpochTime=e.inputObj.inputEpochTime?e.inputObj.inputEpochTime:60*s*60,e.step=e.inputObj.step?e.inputObj.step:15,e.format=e.inputObj.format?e.inputObj.format:24,e.titleLabel=e.inputObj.titleLabel?e.inputObj.titleLabel:"Time Picker",e.setLabel=e.inputObj.setLabel?e.inputObj.setLabel:"Set",e.closeLabel=e.inputObj.closeLabel?e.inputObj.closeLabel:"Close",e.setButtonType=e.inputObj.setButtonType?e.inputObj.setButtonType:"button-positive",e.closeButtonType=e.inputObj.closeButtonType?e.inputObj.closeButtonType:"button-stable";var u={epochTime:e.inputEpochTime,step:e.step,format:e.format};e.time={hours:0,minutes:0,meridian:""};var m=new Date(1e3*u.epochTime);e.increaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(12!=e.time.hours?e.time.hours+=1:e.time.hours=1),24==u.format&&(e.time.hours=(e.time.hours+1)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.decreaseHours=function(){e.time.hours=Number(e.time.hours),12==u.format&&(e.time.hours>1?e.time.hours-=1:e.time.hours=12),24==u.format&&(e.time.hours=(e.time.hours+23)%24),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours},e.increaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+u.step)%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.decreaseMinutes=function(){e.time.minutes=Number(e.time.minutes),e.time.minutes=(e.time.minutes+(60-u.step))%60,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes},e.changeMeridian=function(){e.time.meridian="AM"===e.time.meridian?"PM":"AM"},i.on("click",function(){m="undefined"==typeof e.inputObj.inputEpochTime||null===e.inputObj.inputEpochTime?new Date:new Date(1e3*e.inputObj.inputEpochTime),12==u.format?(e.time.meridian=m.getUTCHours()>=12?"PM":"AM",e.time.hours=m.getUTCHours()>12?m.getUTCHours()-12:m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,0===e.time.hours&&"AM"===e.time.meridian&&(e.time.hours=12),t.show({templateUrl:"ionic-timepicker-12-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=12!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,"AM"===e.time.meridian?i+=0:"PM"===e.time.meridian&&(i+=43200),e.etime=i,e.inputObj.callback(e.etime)}}]})):24==u.format&&(e.time.hours=m.getUTCHours(),e.time.minutes=m.getUTCMinutes(),e.time.hours=e.time.hours<10?"0"+e.time.hours:e.time.hours,e.time.minutes=e.time.minutes<10?"0"+e.time.minutes:e.time.minutes,t.show({templateUrl:"ionic-timepicker-24-hour.html",title:e.titleLabel,subTitle:"",scope:e,buttons:[{text:e.closeLabel,type:e.closeButtonType,onTap:function(t){e.inputObj.callback(void 0)}},{text:e.setLabel,type:e.setButtonType,onTap:function(t){e.loadingContent=!0;var i=0;i=24!=e.time.hours?60*e.time.hours*60+60*e.time.minutes:60*e.time.minutes,e.etime=i,e.inputObj.callback(e.etime)}}]}))})}}}angular.module("ionic-timepicker").directive("ionicTimepicker",t),t.$inject=["$ionicPopup"]}(); \ No newline at end of file diff --git a/src/ionic-timepicker.directive.js b/src/ionic-timepicker.directive.js index 2538991..141c2f8 100644 --- a/src/ionic-timepicker.directive.js +++ b/src/ionic-timepicker.directive.js @@ -86,7 +86,11 @@ }; element.on("click", function () { - objDate = new Date(scope.inputObj.inputEpochTime * 1000); + if (typeof scope.inputObj.inputEpochTime === 'undefined' || scope.inputObj.inputEpochTime === null) { + objDate = new Date(); + } else { + objDate = new Date(scope.inputObj.inputEpochTime * 1000); + } if (obj.format == 12) {