Skip to content

Commit 3a09366

Browse files
author
0x1337
committed
+ Bugfix for leading 0 in 'm' and 's'
1 parent ee8ed0b commit 3a09366

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"devDependencies": {
1616
"grunt": "~0.4.2",
1717
"grunt-exec": "~0.4",
18-
"grunt-contrib-jasmine": "~0.3",
18+
"grunt-contrib-jasmine": "~1.0.3",
1919
"grunt-contrib-watch": "~0.2",
2020
"grunt-contrib-jshint": "~0.7",
2121
"grunt-contrib-uglify": "git://github.com/jharding/grunt-contrib-uglify.git#support-enclose-option",
2222
"grunt-contrib-concat": "~0.1",
2323
"grunt-contrib-jasmine": "~0.3",
24-
"grunt-template-jasmine-istanbul": "~0.2.5"
24+
"grunt-template-jasmine-istanbul": "~0.4.0"
2525
},
2626
"scripts": {
2727
"test": "grunt test --verbose"

src/dateFormat.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ var DateFormat = {};
354354
if(nextRight === 'm') {
355355
break;
356356
}
357-
retValue += time.minute;
357+
retValue += parseInt(time.minute,10);
358358
pattern = '';
359359
break;
360360
case 'ss':
@@ -366,7 +366,7 @@ var DateFormat = {};
366366
if(nextRight === 's') {
367367
break;
368368
}
369-
retValue += time.second;
369+
retValue += parseInt(time.second,10);
370370
pattern = '';
371371
break;
372372
case 'S':
@@ -444,7 +444,7 @@ var DateFormat = {};
444444
}
445445

446446
diff = (((new Date()).getTime() - date.getTime()) / 1000);
447-
447+
448448
abs_diff = Math.abs(diff);
449449
abs_day_diff = Math.floor(abs_diff / 86400);
450450

@@ -453,7 +453,7 @@ var DateFormat = {};
453453
}
454454

455455
tense = diff < 0 ? 'from now' : 'ago';
456-
456+
457457
if(abs_diff < 60) {
458458
if(diff >= 0)
459459
return 'just now';

test/issues_spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,9 @@ describe('issues', function() {
7070
// Leading 0 for "SSS"(milliseconds) is missing
7171
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');
7272
});
73+
74+
it('formats `m s` `2017-05-10 15:02:03`', function() {
75+
//Leading 0 should not appear in these cases
76+
expect($.format.date(new Date(2017, 4, 10, 15, 2, 3), 'm s')).toEqual('2 3');
77+
});
7378
});

0 commit comments

Comments
 (0)