diegoles / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

Problem in goog.date.relative.format() #479

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Code:

var t1 = 1340067920000;
console.log('t1: ' + (new Date(t1)).toLocaleString());
console.log('now: ' + (new Date()).toLocaleString());
console.log('relative: ' + goog.date.relative.format(t1));

generates in my timezone:

t1: Tuesday, June 19, 2012 3:05:20 AM
now: Friday, June 22, 2012 1:27:12 PM
relative: 4 days ago

I think that it should generate:

...
relative: 3 days ago

To repeat the problem in another timezone you will need to choose another 
timestamp.

I think the problem is in 2 lines of goog.date.relative.format():

delta = Math.floor((now + offset)      ...
        Math.floor((dateMs + offset)   ...

There should be 

delta = Math.floor((now - offset)      ...
        Math.floor((dateMs - offset)   ...

Original issue reported on code.google.com by Li...@tibosoftware.com on 22 Jun 2012 at 11:51

GoogleCodeExporter commented 8 years ago
goog.date.relative.format() was already remade, issue is out of date.

Original comment by Li...@tibosoftware.com on 15 Nov 2012 at 3:25