Skip to content

Commit b34e0e6

Browse files
committed
fix: accept leap seconds in isoTimestamp validation
1 parent 5ee998c commit b34e0e6

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function isValidDate(year: number, month: number, day: number): boolean {
2727
function isValidTime(hours: number, minutes: number, seconds: number): boolean {
2828
return hours >= 0 && hours <= 23
2929
&& minutes >= 0 && minutes <= 59
30-
&& seconds >= 0 && seconds <= 59;
30+
&& seconds >= 0 && seconds <= 60;
3131
}
3232

3333
export const schema = {

tests/schema.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ describe('schema.isoTimestamp', () => {
111111
expect(schema.isoTimestamp.validate('2024-02-30T12:00:00Z')).toBe(false);
112112
expect(schema.isoTimestamp.validate('2024-01-01T25:00:00Z')).toBe(false);
113113
expect(schema.isoTimestamp.validate('2024-01-01T12:60:00Z')).toBe(false);
114-
expect(schema.isoTimestamp.validate('2024-01-01T12:00:60Z')).toBe(false);
114+
expect(schema.isoTimestamp.validate('2024-01-01T12:00:61Z')).toBe(false);
115+
});
116+
117+
it('accepts leap second (seconds = 60)', () => {
118+
expect(schema.isoTimestamp.validate('2016-12-31T23:59:60Z')).toBe(true);
115119
});
116120
});
117121

0 commit comments

Comments
 (0)