Skip to content

Commit

Permalink
feat(date-fns): update to v3 [MA-2651] (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-peteu authored Sep 6, 2024
1 parent a2ff0e6 commit 89ff83a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/analytics/analytics-chart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
"chart.js": "^4.4.3",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-annotation": "^3.0.1",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.1",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"pretty-bytes": "^6.1.1",
"uuid": "^9.0.1",
"vue-chartjs": "^5.3.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/analytics-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"errorLimit": "500KB"
},
"dependencies": {
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.1"
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3"
},
"devDependencies": {
"@kong/design-tokens": "1.17.2"
Expand Down
6 changes: 3 additions & 3 deletions packages/analytics/analytics-utilities/src/timeframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
RelativeTimeRangeValuesV4, TimeRangeV4,
GranularityValues,
} from './types'
import { getTimezoneOffset, utcToZonedTime, zonedTimeToUtc } from 'date-fns-tz'
import { getTimezoneOffset, toZonedTime, fromZonedTime } from 'date-fns-tz'
import type { ITimeframe } from './types/timeframe'

const adjustForTz = (d: Date, tz: string) => {
Expand Down Expand Up @@ -156,8 +156,8 @@ export class Timeframe implements ITimeframe {

// Take `new Date()` and adjust it so that it's within the given TZ
// instead of the current environment's TZ.
const tzNeutral = zonedTimeToUtc(new Date(), (new Intl.DateTimeFormat()).resolvedOptions().timeZone)
return utcToZonedTime(tzNeutral, tz)
const tzNeutral = fromZonedTime(new Date(), (new Intl.DateTimeFormat()).resolvedOptions().timeZone)
return toZonedTime(tzNeutral, tz)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"vue": "^3.4.31"
},
"dependencies": {
"date-fns": "^2.30.0"
"date-fns": "^3.6.0"
},
"devDependencies": {
"@kong/design-tokens": "1.17.2",
Expand Down
41 changes: 27 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 89ff83a

Please sign in to comment.