Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/dateFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ var DateFormat = {};
if(nextRight === 'm') {
break;
}
retValue += time.minute;
retValue += parseInt(time.minute,10);
pattern = '';
break;
case 'ss':
Expand All @@ -366,7 +366,7 @@ var DateFormat = {};
if(nextRight === 's') {
break;
}
retValue += time.second;
retValue += parseInt(time.second,10);
pattern = '';
break;
case 'S':
Expand Down Expand Up @@ -444,7 +444,7 @@ var DateFormat = {};
}

diff = (((new Date()).getTime() - date.getTime()) / 1000);

abs_diff = Math.abs(diff);
abs_day_diff = Math.floor(abs_diff / 86400);

Expand All @@ -453,7 +453,7 @@ var DateFormat = {};
}

tense = diff < 0 ? 'from now' : 'ago';

if(abs_diff < 60) {
if(diff >= 0)
return 'just now';
Expand Down
5 changes: 5 additions & 0 deletions test/issues_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ describe('issues', function() {
// Leading 0 for "SSS"(milliseconds) is missing
expect($.format.date(new Date(2015, 4, 6, 15, 32, 12, 34), 'MM/dd/yyyy HH:mm:ss.SSS')).toEqual('05/06/2015 15:32:12.034');
});

it('formats `m s` `2017-05-10 15:02:03`', function() {
//Leading 0 should not appear in these cases
expect($.format.date(new Date(2017, 4, 10, 15, 2, 3), 'm s')).toEqual('2 3');
});
});