|
20 | 20 | var today = new Date();
|
21 | 21 | var currentEpoch = ((new Date()).getHours() * 60 * 60) + ((new Date()).getMinutes() * 60);
|
22 | 22 |
|
| 23 | + //set up base variables and options for customization |
23 | 24 | scope.inputEpochTime = scope.inputObj.inputEpochTime ? scope.inputObj.inputEpochTime : currentEpoch;
|
24 | 25 | scope.step = scope.inputObj.step ? scope.inputObj.step : 15;
|
25 | 26 | scope.format = scope.inputObj.format ? scope.inputObj.format : 24;
|
|
33 | 34 | scope.time = {hours: 0, minutes: 0, meridian: ""};
|
34 | 35 | var objDate = new Date(obj.epochTime * 1000); // Epoch time in milliseconds.
|
35 | 36 |
|
| 37 | + //Increasing the hours |
36 | 38 | scope.increaseHours = function () {
|
37 | 39 | scope.time.hours = Number(scope.time.hours);
|
38 | 40 | if (obj.format == 12) {
|
|
48 | 50 | scope.time.hours = (scope.time.hours < 10) ? ('0' + scope.time.hours) : scope.time.hours;
|
49 | 51 | };
|
50 | 52 |
|
| 53 | + //Decreasing the hours |
51 | 54 | scope.decreaseHours = function () {
|
52 | 55 | scope.time.hours = Number(scope.time.hours);
|
53 | 56 | if (obj.format == 12) {
|
|
63 | 66 | scope.time.hours = (scope.time.hours < 10) ? ('0' + scope.time.hours) : scope.time.hours;
|
64 | 67 | };
|
65 | 68 |
|
| 69 | + //Increasing the minutes |
66 | 70 | scope.increaseMinutes = function () {
|
67 | 71 | scope.time.minutes = Number(scope.time.minutes);
|
68 | 72 | scope.time.minutes = (scope.time.minutes + obj.step) % 60;
|
69 | 73 | scope.time.minutes = (scope.time.minutes < 10) ? ('0' + scope.time.minutes) : scope.time.minutes;
|
70 | 74 | };
|
71 | 75 |
|
| 76 | + //Decreasing the minutes |
72 | 77 | scope.decreaseMinutes = function () {
|
73 | 78 | scope.time.minutes = Number(scope.time.minutes);
|
74 | 79 | scope.time.minutes = (scope.time.minutes + (60 - obj.step)) % 60;
|
75 | 80 | scope.time.minutes = (scope.time.minutes < 10) ? ('0' + scope.time.minutes) : scope.time.minutes;
|
76 | 81 | };
|
77 | 82 |
|
| 83 | + //Changing the meridian |
78 | 84 | scope.changeMeridian = function () {
|
79 | 85 | scope.time.meridian = (scope.time.meridian === "AM") ? "PM" : "AM";
|
80 | 86 | };
|
81 | 87 |
|
| 88 | + //onclick of the button |
82 | 89 | element.on("click", function () {
|
83 | 90 | if (typeof scope.inputObj.inputEpochTime === 'undefined' || scope.inputObj.inputEpochTime === null) {
|
84 | 91 | objDate = new Date();
|
|
0 commit comments