Skip to content

Commit

Permalink
Fix data builder to use UTC in one case
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdemartini committed Sep 29, 2020
1 parent 89dac56 commit 3bac4c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/data-mate/src/builder/types/DateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class DateBuilder extends Builder<DateValue> {
if (!thisArg.config.format) {
thisArg.config.format = DateFormat.iso_8601;
}
return new DateValue(date.getTime(), date.toISOString());
return new DateValue(date.getTime() - systemTimezoneOffset, date.toISOString());
}

if (!thisArg.config.format) {
Expand Down
22 changes: 13 additions & 9 deletions packages/data-mate/test/column/column-date-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ describe('Column (Date Types)', () => {
...col.config,
type: FieldType.String
});
expect(newCol.toJSON()).toEqual(values.map((value) => {
if (value == null) return null;
return new Date(value).toISOString();
}));
expect(newCol.toJSON()).toEqual([
'2020-09-23T14:54:21.020Z',
'1941-08-20T07:00:00.000Z',
'2020-09-23T00:00:00.000Z',
'2020-09-23T15:32:18.416Z',
null,
'2019-01-20T12:50:20.000Z'
]);
});

it('should be able to transform using formatDate(format: "yyyy-MM-dd HH:mm:ss")', () => {
Expand All @@ -73,12 +77,12 @@ describe('Column (Date Types)', () => {
type: FieldType.Date
});
expect(newCol.toJSON()).toEqual([
'2020-09-23 07:54:21',
'1941-08-20 00:00:00',
'2020-09-22 17:00:00',
'2020-09-23 08:32:18',
'2020-09-23 00:54:21',
'1941-08-19 17:00:00',
'2020-09-22 10:00:00',
'2020-09-23 01:32:18',
null,
'2019-01-20 05:50:20',
'2019-01-19 22:50:20',
]);
});

Expand Down

0 comments on commit 3bac4c9

Please sign in to comment.