Skip to content

Commit a0e8181

Browse files
committed
- (Refactor) Made the getMilitaryTime and getTime objects capable of returning time relative to a datestamp passed as an argument instead of always assuming to current time
1 parent 4b865d1 commit a0e8181

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/flipclock/js/libs/time.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
FlipClock.Time = FlipClock.Base.extend({
2626

2727
/**
28-
* The time (in seconds)
28+
* The time (in seconds) or a date object
2929
*/
3030

3131
time: 0,
@@ -116,7 +116,7 @@
116116

117117
digitize: function(obj) {
118118
var data = [];
119-
119+
120120
$.each(obj, function(i, value) {
121121
value = value.toString();
122122

@@ -138,7 +138,7 @@
138138
data.unshift('0');
139139
}
140140
}
141-
141+
142142
return data;
143143
},
144144

@@ -228,8 +228,11 @@
228228
* @return object returns a digitized object
229229
*/
230230

231-
getMilitaryTime: function() {
232-
var date = new Date();
231+
getMilitaryTime: function(date) {
232+
if(!date) {
233+
date = this.getDateObject();
234+
}
235+
233236
var obj = this.digitize([
234237
date.getHours(),
235238
date.getMinutes(),

0 commit comments

Comments
 (0)