Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(xapi/parseDateTime): handle date objects (#6701)
Fixes zammad#12622 zammad#13106 zammad#13136 zammad#13162
- Loading branch information
Showing
9 changed files
with
99 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
const assert = require('node:assert/strict') | ||
const test = require('test') | ||
|
||
const { parseDateTime } = require('./') | ||
|
||
test('parseDateTime()', function () { | ||
for (const [input, output] of [ | ||
// number | ||
[0, null], | ||
[1678040309, 1678040309], | ||
|
||
// string | ||
['19700101T00:00:00Z', null], | ||
['20230305T18:18:29Z', 1678040309], | ||
['0', null], | ||
['1675817747.', 1675817747], | ||
['1647628715.91', 1647628715.91], | ||
|
||
// date | ||
[new Date(0), null], | ||
[new Date(1678040309000), 1678040309], | ||
]) { | ||
assert.equal(parseDateTime(input), output) | ||
} | ||
}) | ||
|
||
test('failing parseDateTime()' , function(){ | ||
for (const [input, error] of [ | ||
// object | ||
[{}, TypeError], | ||
[undefined, TypeError], | ||
|
||
// string | ||
['XXX 03/10/2010', RangeError] | ||
]) { | ||
assert.throws(() => parseDateTime(input), error) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters