Skip to content

Commit 7070565

Browse files
committed
- (Bug Fix) Changed the way the getTimeSeconds method works. Now a date object can be passed to get the time relative to the date instead of always being the current time
1 parent 2d094d5 commit 7070565

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/flipclock/js/libs/time.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,19 @@
267267
* @return int Returns a floored integer
268268
*/
269269

270-
getTimeSeconds: function(mod) {
270+
getTimeSeconds: function(date) {
271+
if(!date) {
272+
date = new Date();
273+
}
274+
271275
if (this.time instanceof Date) {
272276
if (this.factory.countdown) {
273-
if ((new Date()).getTime() > this.time.getTime()) {
277+
if (date.getTime() > this.time.getTime()) {
274278
this.factory.stop();
275279
}
276-
return Math.max(this.time.getTime()/1000 - (new Date()).getTime()/1000,0);
280+
return Math.max(this.time.getTime()/1000 - date.getTime()/1000,0);
277281
} else {
278-
return (new Date()).getTime()/1000 - this.time.getTime()/1000 ;
282+
return date.getTime()/1000 - this.time.getTime()/1000 ;
279283
}
280284
} else {
281285
return this.time;

0 commit comments

Comments
 (0)