Skip to content

Commit 78192d0

Browse files
committed
put back *another* bit of required behavior - <3 tests!
1 parent 70a0a36 commit 78192d0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/lib/dates.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,12 @@ function formatTime(x, tr) {
423423
*/
424424
var sec = Math.min(mod(x / ONESEC, 60), MAXSECONDS[tr]);
425425

426-
timeStr += ':' + (
427-
(100 + sec).toFixed(tr).substr(1).replace(/[\.]?0*$/, '')
428-
);
426+
var secStr = (100 + sec).toFixed(tr).substr(1);
427+
if(tr > 0) {
428+
secStr = secStr.replace(/0+$/, '').replace(/[\.]$/, '');
429+
}
430+
431+
timeStr += ':' + secStr;
429432
}
430433
return timeStr;
431434
}

test/jasmine/tests/lib_date_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ describe('dates', function() {
590590
it('should remove extra fractional second zeros', function() {
591591
expect(Lib.formatDate(0.1, '', 4)).toBe('00:00:00.0001\nJan 1, 1970');
592592
expect(Lib.formatDate(0.1, '', 3)).toBe('00:00:00\nJan 1, 1970');
593+
expect(Lib.formatDate(0.1, '', 0)).toBe('00:00:00\nJan 1, 1970');
594+
expect(Lib.formatDate(0.1, '', 'S')).toBe('00:00:00\nJan 1, 1970');
593595
expect(Lib.formatDate(0.1, '', 3, 'coptic'))
594596
.toBe('00:00:00\nKoi 23, 1686');
595597

0 commit comments

Comments
 (0)