fix: import with datetime no tz field (#5614)

* fix: import with datetime no tz field

* chore: console.log

* chore: console.log
This commit is contained in:
ChengLei Shao 2024-11-08 11:41:56 +08:00 committed by GitHub
parent e08b9e57e7
commit 85a6c171fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -32,7 +32,7 @@ export class DatetimeNoTzInterface extends DatetimeInterface {
return value;
} else if (isNumeric(value)) {
const date = getJsDateFromExcel(value);
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
return date.toISOString();
} else if (typeof value === 'string') {
return value;
}

View File

@ -148,7 +148,8 @@ describe('xlsx importer', () => {
worksheet,
[
['test', 77383],
['test2', '2021-10-18'],
['test2', '2021-10-18 12:31:20'],
['test3', 41557.4377314815],
],
{ origin: 'A2' },
);
@ -164,7 +165,8 @@ describe('xlsx importer', () => {
const users = (await User.repository.find()).map((user) => user.toJSON());
expect(users[0]['datetimeNoTz']).toBe('2111-11-12 00:00:00');
expect(users[1]['datetimeNoTz']).toBe('2021-10-18 00:00:00');
expect(users[1]['datetimeNoTz']).toBe('2021-10-18 12:31:20');
expect(users[2]['datetimeNoTz']).toBe('2013-10-10 10:30:20');
});
it('should import with unixTimestamp', async () => {