Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data-mate, utils, xlucene-parser] update date-fns and date-fns-tz #3783

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/data-mate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@terascope/utils": "^1.2.0",
"@types/validator": "^13.12.2",
"awesome-phonenumber": "^7.1.0",
"date-fns": "^2.30.0",
"date-fns": "^4.1.0",
"ip-bigint": "^8.2.0",
"ip6addr": "^0.2.5",
"ipaddr.js": "^2.2.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/data-mate/src/transforms/field-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,9 @@ function _parseDate(input: any, args: ParseDateConfig) {
throw new Error(`Invalid parameter format, must be a string, received ${ts.getTypeOf(input)}`);
}

const parsed = parse(input, format, new Date());
const inputStr = String(input);

const parsed = parse(inputStr, format, new Date());

if (!ts.isValidDateInstance(parsed)) {
throw new Error('Cannot parse date');
Expand Down
2 changes: 1 addition & 1 deletion packages/data-mate/test/column/column-date-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'jest-extended';
import { getValidDate, timezoneOffset } from '@terascope/utils';
import { DateFormat, FieldType, Maybe } from '@terascope/types';
import formatDate from 'date-fns/format';
import { formatDate } from 'date-fns/format';
import {
Column, dataFrameAdapter, functionConfigRepository, Vector
} from '../../src/index.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import addDays from 'date-fns/addDays';
import { addDays } from 'date-fns/addDays';
import { xLuceneFieldType } from '@terascope/types';
import { TestCase } from './interfaces.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"@types/lodash-es": "^4.17.12",
"@types/validator": "^13.12.2",
"awesome-phonenumber": "^7.1.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^1.3.7",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"datemath-parser": "^1.0.6",
"debug": "^4.3.7",
"geo-tz": "^8.1.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/utils/src/dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
DateFormat, ISO8601DateSegment, DateTuple,
DateInputTypes, GetTimeBetweenArgs
} from '@terascope/types';
import dateTimezonePkg from 'date-fns-tz';
import { getTimezoneOffset as tzOffset } from 'date-fns-tz';
import { getTypeOf } from './deps.js';
import {
bigIntToJSON, isNumber, toInteger,
Expand All @@ -47,8 +47,6 @@ import { isString } from './strings.js';
import { isBoolean } from './booleans.js';
import { lookupTimezone } from './geo.js';

const { getTimezoneOffset: tzOffset } = dateTimezonePkg;

// date-fns doesn't handle utc correctly here
// https://github.com/date-fns/date-fns/issues/376
// https://github.com/date-fns/date-fns/blob/d0efa9eae1cf05c0e27461296b537b9dd46283d4/src/format/index.js#L399-L403
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/data-entity-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'jest-extended';
import addDays from 'date-fns/addDays';
import { addDays } from 'date-fns/addDays';
import {
DataEntity, DataEncoding, __IS_DATAENTITY_KEY,
__ENTITY_METADATA_KEY, DataEntityMetadata,
Expand Down
4 changes: 2 additions & 2 deletions packages/xlucene-parser/test/cases/range-date-math.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { xLuceneFieldType } from '@terascope/types';
import subDays from 'date-fns/subDays';
import addDays from 'date-fns/addDays';
import { subDays } from 'date-fns/subDays';
import { addDays } from 'date-fns/addDays';
import { NodeType, Node } from '../../src';
import { TestCase } from './interfaces.js';

Expand Down
4 changes: 2 additions & 2 deletions packages/xlucene-parser/test/cases/term.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import subDays from 'date-fns/subDays';
import addDays from 'date-fns/addDays';
import { subDays } from 'date-fns/subDays';
import { addDays } from 'date-fns/addDays';
import { xLuceneFieldType } from '@terascope/types';
import { escapeString } from '@terascope/utils';
import { NodeType, Term } from '../../src/index.js';
Expand Down
20 changes: 9 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.24.8"

"@babel/runtime@^7.10.2", "@babel/runtime@^7.16.3", "@babel/runtime@^7.21.0", "@babel/runtime@^7.8.4":
"@babel/runtime@^7.10.2", "@babel/runtime@^7.16.3", "@babel/runtime@^7.8.4":
version "7.25.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.25.6.tgz#9afc3289f7184d8d7f98b099884c26317b9264d2"
integrity sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==
Expand Down Expand Up @@ -5005,17 +5005,15 @@ data-view-byte-offset@^1.0.0:
es-errors "^1.3.0"
is-data-view "^1.0.1"

date-fns-tz@^1.3.7:
version "1.3.8"
resolved "https://registry.yarnpkg.com/date-fns-tz/-/date-fns-tz-1.3.8.tgz#083e3a4e1f19b7857fa0c18deea6c2bc46ded7b9"
integrity sha512-qwNXUFtMHTTU6CFSFjoJ80W8Fzzp24LntbjFFBgL/faqds4e5mo9mftoRLgr3Vi1trISsg4awSpYVsOQCRnapQ==
date-fns-tz@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/date-fns-tz/-/date-fns-tz-3.2.0.tgz#647dc56d38ac33a3e37b65e9d5c4cda5af5e58e6"
integrity sha512-sg8HqoTEulcbbbVXeg84u5UnlsQa8GS5QXMqjjYIhS4abEVVKIUwe0/l/UhrZdKaL/W5eWZNlbTeEIiOXTcsBQ==

date-fns@^2.30.0:
version "2.30.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0"
integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==
dependencies:
"@babel/runtime" "^7.21.0"
date-fns@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-4.1.0.tgz#64b3d83fff5aa80438f5b1a633c2e83b8a1c2d14"
integrity sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==

dateformat@^4.5.0:
version "4.6.3"
Expand Down
Loading