urish/angular-moment

amDifference : null : 'days' is returning days in negative

Closed this issue · 2 comments

I am getting a mysql DateTime to amDifference filter like this

// created_at = "2014-03-20 20:11:42"
{{ user.created_at |  amDifference : null : 'days' }}  

but its returning me -622 days, whats wrong, How can I get days in positive number.

I am using "angular-moment": "1.0.0-beta.3" to support amLocal as described in docs

I think problem is here https://github.com/urish/angular-moment/blob/1.0.0-beta.3/angular-moment.js#L547

You should get difference from date2,

 return date2.diff(date, unit, usePrecision);

That's because that day was 622 days ago (more now)

It was api fault, date was wrong