I have great news! First, ten years after its release, date-fns finally gets first-class time zone support.
Another great news is that there aren't many breaking changes in this release. All of them are type-related and will affect only those explicitly using internal date-fns types. Finally, it has been less than a year since the last major release, which is an improvement over the previous four years between v2 and v3. I plan on keeping the pace and minimizing breaking changes moving forward.
Added time zones support via @date-fns/tz's TZDate class and tz helper function. See its README for the details about the API.
All relevant functions now accept the context in option, which allows to specify the time zone to make the calculations in. If the function also returns a date, it will be in the specified time zone:
import { addDays, startOfDay } from "date-fns";
import { tz } from "@date-fns/tz";
In the example, addDays will get the current date and time in Singapore and add 5 days to it. startOfDay will inherit the date type and return the start of the day in Singapore.
Changed
The function arguments, as well as Interval's start and end, now can be of different types, allowing you to mix UTCDate, TZDate, Date, and other extensions, as well as primitives (strings and numbers).
The functions will normalize these values, make calculations, and return the result in the same type, preventing any bugs caused by the discrepancy. If passed, the type will be inferred from the context in option or the first encountered argument object type. The Interval's start and end will be considered separately, starting from start.
In the given example, the result will be in the TZDate as the first argument is a number, and the start takes precedence over the end.
clamp(Date.now(), {
start: new TZDate(start, "Asia/Singapore"),
end: new UTCDate(),
});
//=> TZDate
BREAKING: This release contains a bunch of types changes that should not affect the library's expected usage. The changes are primarily internal and nuanced, so rather than listing them here, I recommend you running the type checker after the upgrade. If there are unfixable problems, please open an issue.
BREAKING: The package now is ESM-first. The CommonJS is still support and It should not affect most users, but it might break in certains environments. If you encounter any issues, please report them.
Fixed
Fixed CDN build compatibility with jQuery and other tools that expose $ by properly wrapping the code in an IIFE.
Bumps the everything-else group with 16 updates in the /frontend directory:
5.0.5
5.1.3
3.6.0
4.0.0
3.1.5
3.1.6
9.6.0
9.10.0
9.27.0
9.28.0
12.0.1
14.1.2
0.2.10
0.2.12
2.1.7
2.2.2
3.3.2
3.3.3
5.5.3
5.6.2
5.3.2
5.4.5
2.0.3
2.0.4
3.4.31
3.5.5
4.4.0
4.4.5
2.0.24
2.1.6
3.6.10
3.7.1
Updates
@vitejs/plugin-vue
from 5.0.5 to 5.1.3Release notes
Sourced from
@vitejs/plugin-vue
's releases.Changelog
Sourced from
@vitejs/plugin-vue
's changelog.Commits
3ef2b6e
release: plugin-vue@5.1.3b75a46f
chore(deps): update upstream (#436)acb57c9
fix(plugin-vue): default value for__VUE_OPTIONS_API__
e3a7fec
fix(deps): update all non-major dependencies (#421)236a40f
chore: upgrade to eslint 937c9073
chore(deps): update dependency rollup to ^4.20.0 (#433)0735e18
chore: use pnpm catalog for shared deps182ff56
release: plugin-vue@5.1.2a6b7e3f
refactor(plugin-vue): addtype
field1e24322
fix(plugin-vue): add deprecatedscript.propsDestructure
optionUpdates
date-fns
from 3.6.0 to 4.0.0Changelog
Sourced from date-fns's changelog.
Commits
Updates
dompurify
from 3.1.5 to 3.1.6Release notes
Sourced from dompurify's releases.
Commits
4083a90
Merge pull request #978 from cure53/main90a10a1
fix: Fixed a typo on the README65df042
chore: Preparing 3.1.6 release6e03334
fix: Made sure that remove() is not called directly from node00fc06c
fix: Fixed a DOM clobbering issue leading to an error being thrownf8c2ef5
Merge pull request #977 from cure53/dependabot/npm_and_yarn/multi-99ca4f73d8e5112ec
build(deps): bump ws and socket.io-adapter9978cec
docs: Added better security warning about SAFE_FOR_XML to READMEfa542df
fix: Changed the order for attribute checks slightly for safer hooksb8b552c
Merge pull request #975 from cure53/dependabot/npm_and_yarn/multi-2d3aef8690Updates
eslint
from 9.6.0 to 9.10.0Release notes
Sourced from eslint's releases.
... (truncated)
Changelog
Sourced from eslint's changelog.
... (truncated)
Commits
6448f32
9.10.0afeb9b1
Build: changelog update for 9.10.024c3ff7
chore: upgrade to@eslint/js
@9
.10.0 (#18866)1ebdde1
chore: package.json update for@eslint/js
release301b90d
feat: Add types (#18854)bee0e7a
docs: update README (#18865)bcf0df5
feat: limit namespace import identifier in id-length rule (#18849)45c18e1
feat: addrequireFlag
option torequire-unicode-regexp
rule (#18836)5d80b59
docs: specify thatruleId
can benull
in custom formatter docs (#18857)156b1c3
docs: Update READMEUpdates
eslint-plugin-vue
from 9.27.0 to 9.28.0Release notes
Sourced from eslint-plugin-vue's releases.
Commits
d77fbf7
9.28.0889c192
feat(require-toggle-inside-transition): add additionalDirectives option (#253...354c0de
fix(attribute-hyphenation): apply to v-model directive (#2511)21d3ed8
fix(no-deprecated-slot-attribute): no fix for dynamic components (#2530)b08273c
fix(no-deprecated-slot-attribute): handle v-for with dynamic slot (#2529)ddc0525
fix(attribute-hyphenation): skip auto-fix when suffixed with.sync
(#2533)a4aed0a
Implements proposed max-template-depth rule (#2525)6ebd607
Update ruledefine-macros-order
for custom macros (#2501)0fbe35e
Improve error range forvue/max-props
(#2532)705d262
Fix code example invue/define-props-declaration
docs (#2527)Updates
marked
from 12.0.1 to 14.1.2Release notes
Sourced from marked's releases.
... (truncated)
Commits
0309c2f
chore(release): 14.1.2 [skip ci]9d7b728
fix: fix html following list (#3444)2fe4136
chore: update testutils to v14.1.1-0 (#3443)f3c387f
chore(release): 14.1.1 [skip ci]9ed6456
fix: Don't replace tabs with spaces (#3438)2ff0547
chore(deps-dev): Bump@markedjs/eslint-config
from 1.0.1 to 1.0.2 (#3442)e6167a9
chore(deps-dev): Bump rollup from 4.21.0 to 4.21.2 (#3441)2124b5d
chore: update@marked/testutils
(#3431)e6f0ca5
chore(deps-dev): Bump eslint from 9.9.0 to 9.9.1 (#3430)73d21f4
chore(deps-dev): Bump tslib from 2.6.3 to 2.7.0 (#3429)Updates
pdfmake
from 0.2.10 to 0.2.12Release notes
Sourced from pdfmake's releases.
Changelog
Sourced from pdfmake's changelog.
Commits
dc73c5a
0.2.12757735f
fixed error message of bad image definitiond0d8133
0.2.11c40c0b2
refresh pdfs examples107d298
Update CHANGELOG.md07ec20b
backport PR #2764508d120
Update CHANGELOG.md95240e0
backport PR #2762d8f0ff0
Update CHANGELOG.mdc7caabb
Merge pull request #2733 from estanglerbm/stylecontext_autopush_faster_overrideUpdates
pinia
from 2.1.7 to 2.2.2Release notes
Sourced from pinia's releases.
Commits
b1564c9
release: pinia@2.2.23069105
feat: improve tree shaking ondefineStore
(#2740)b90c595
release:@pinia/nuxt
@0
.5.3 pinia@2.2.1@pinia/testing
@0
.1.5ffba3ec
build: fix release scripte8e93e4
refactor(types): remove export from augmentation82ca41c
fix(types): breaking type with auto imported components (#2730)a46a31e
chore: fix types nuxt modulec6e03ae
docs: use nuxi module39c563a
docs: remove duplicated sentence (#2726)557f0aa
test: pending testsUpdates
prettier
from 3.3.2 to 3.3.3Release notes
Sourced from prettier's releases.
Changelog
Sourced from prettier's changelog.
... (truncated)
Commits
5282938
Release 3.3.39102b73
Add parentheses for decorator expressions (#16458)6bbd461
chore(deps): update eslint related dependencies (#16478)04b560f
chore(deps): update dependency browserslist to v4.23.2 (#16475)614f070
chore(deps): update typescript-eslint to v8.0.0-alpha.41 (#16477)d59a15d
chore(deps): update dependency npm-run-all2 to v6.2.2 (#16476)5ca2fc9
Support Angular@let
declaration syntax (#16474)bfcfdcc
chore(deps): update babel to v7.24.8 (#16472)977c161
chore(deps): update dependency acorn to v8.12.1 (#16464)550606e
chore(deps): update babel to v7.24.8 (#16470)Updates
typescript
from 5.5.3 to 5.6.2Release notes
Sourced from typescript's releases.