Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-fns

Package Overview
Dependencies
Maintainers
2
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-fns - npm Package Versions

23
21

4.1.0

Diff

Changelog

Source

v4.1.0 - 2024-09-17

This release adds time zone support to format functions (that I somehow missed when working on the feature) and fixes a few bugs.

Make sure also upgrade TZDate to v1.0.2 as it includes a bunch of critical bug fixes.

Fixed

  • Fixed internal constructFrom throwing an exception on null arguments. While null isn't allowed, the functions should rather return Invalid Date or NaN in such cases. See #3885.

Added

  • Added missing time zone support to format, formatISO, formatISO9075, formatRelative and formatRFC3339. See #3886.
kossnocorp
published 4.0.0 •

Changelog

Source

v4.0.0 - 2024-09-??

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.

Read more about the release in the announcement blog post.

- Sasha @kossnocorp

Added

  • 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";
    
    startOfDay(addDays(Date.now(), 5, { in: tz("Asia/Singapore") }));
    //=> "2024-09-16T00:00:00.000+08:00"
    

    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.
kossnocorp
published 4.0.0-beta.1 •

kossnocorp
published 4.0.0-alpha.1 •

kossnocorp
published 3.6.0 •

Changelog

Source
kossnocorp
published 3.5.0 •

Changelog

Source

v3.5.0 - 2024-03-15

Kudos to @fturmel, @kossnocorp, @makstyle119, @tan75, @marcreichel, @tareknatsheh and @audunru for working on the release. Also, thanks to @seated for sponsoring me.

Fixed

Added

kossnocorp
published 3.4.0 •

Changelog

Source

v3.4.0 - 2024-03-11

Kudos to @kossnocorp, @sakamossan and @Revan99 for working on the release. Also, thanks to @seated for sponsoring me.

Added

kossnocorp
published 3.3.1 •

Changelog

Source

v3.3.1 - 2024-01-22

Kudos to @kossnocorp and @fturmel for working on the release.

Fixed

  • Fixed DST issue in getOverlappingDaysInIntervals, resulting in an inconsistent number of days returned for intervals starting and ending in different DST periods.

  • Fixed functions incorrectly using trunc instead of round. The bug was introduced in v3.3.0. The affected functions: differenceInCalendarDays, differenceInCalendarISOWeeks, differenceInCalendarWeeks, getISOWeek, getWeek, and getISOWeeksInYear.

kossnocorp
published 3.3.0 •

Changelog

Source

v3.3.0 - 2024-01-20

On this release worked @kossnocorp, @TheKvikk, @fturmel and @ckcherry23.

Fixed

  • Fixed the bug in getOverlappingDaysInIntervals caused by incorrect sorting of interval components that led to 0 for timestamps of different lengths.

  • Fixed bugs when working with negative numbers caused by using Math.floor (-1.1-2) instead of Math.trunc (-1.1-1). Most of the conversion functions (i.e., hoursToMinutes) were affected when passing some negative fractional input. Also, some other functions that could be possibly affected by unfortunate timezone/date combinations were fixed.

    The functions that were affected: format, parse, getUnixTime, daysToWeeks, hoursToMilliseconds, hoursToMinutes, hoursToSeconds, milliseconds, minutesToMilliseconds, millisecondsToMinutes, monthsToYears, millisecondsToHours, millisecondsToSeconds, minutesToHours, minutesToSeconds, yearsToQuarters, yearsToMonths, yearsToDays, weeksToDays, secondsToMinutes, secondsToHours, quartersToYears, quartersToMonths and monthsToQuarters.

  • Fixed the Czech locale's formatDistance to include 1 in formatDistance.

  • Fixed differenceInSeconds and other functions relying on rounding options that can produce a negative 0.

  • Added a preprocessor to the locales API, enabling fixing a long-standing bug in the French locale. (#1391)

  • Added missing yearsToDays to the FP submodule.

  • Made functions using rounding methods always return 0 instead of -0.

Added

kossnocorp
published 3.2.0 •

Changelog

Source

v3.2.0 - 2024-01-09

This release is brought to you by @kossnocorp, @fturmel, @grossbart, @MelvinVermeer, and @jcarstairs-scottlogic.

Fixed

Added

  • Added exports of format, lightFormat, and parse internals that enable 3rd-parties to consume those.
23
21
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc