Skip to content

Commit 329976f

Browse files
committed
- (Refactor) Added param to the getTime and getMilitaryTime methods to hide the seconds from being returned
1 parent 928b280 commit 329976f

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

src/flipclock/js/libs/time.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
return this.time;
154154
}
155155

156-
return new Date(this.getTimeSeconds());
156+
return new Date((new Date()).getTime() + this.getTimeSeconds() * 1000);
157157
},
158158

159159
/**
@@ -242,17 +242,24 @@
242242
* @return object returns a digitized object
243243
*/
244244

245-
getMilitaryTime: function(date) {
245+
getMilitaryTime: function(date, showSeconds) {
246+
if(typeof showSeconds === "undefined") {
247+
showSeconds = true;
248+
}
249+
246250
if(!date) {
247251
date = this.getDateObject();
248252
}
249253

250254
var obj = this.digitize([
251255
date.getHours(),
252-
date.getMinutes(),
253-
date.getSeconds()
256+
date.getMinutes()
254257
]);
255258

259+
if(showSeconds === true) {
260+
date.getSeconds();
261+
}
262+
256263
return obj;
257264
},
258265

@@ -314,20 +321,30 @@
314321
* @return object Returns a digitized object
315322
*/
316323

317-
getTime: function(date) {
324+
getTime: function(date, showSeconds) {
325+
if(typeof showSeconds === "undefined") {
326+
showSeconds = true;
327+
}
328+
318329
if(!date) {
319330
date = this.getDateObject();
320331
}
332+
333+
console.log(date);
334+
321335

322336
var hours = date.getHours();
323337
var merid = hours > 12 ? 'PM' : 'AM';
324-
var obj = this.digitize([
338+
var data = [
325339
hours > 12 ? hours - 12 : (hours === 0 ? 12 : hours),
326-
date.getMinutes(),
327-
date.getSeconds()
328-
]);
340+
date.getMinutes()
341+
];
329342

330-
return obj;
343+
if(showSeconds === true) {
344+
data.push(date.getSeconds());
345+
}
346+
347+
return this.digitize(data);
331348
},
332349

333350
/**
@@ -359,7 +376,7 @@
359376
* @return int Retuns a floored integer
360377
*/
361378

362-
getWeeks: function(mod) {
379+
getWeeks: function() {
363380
var weeks = this.getTimeSeconds() / 60 / 60 / 24 / 7;
364381

365382
if(mod) {

0 commit comments

Comments
 (0)