Fixed the content of the package.
Previous release introduced an additional layer of subdirectories, which ruined all the imports on users' projects.
Ensured Chronos supports Node.js 18.
Improved types of parseDate
: format
always has been an optional param, but has not been marked as such.
Improved type coercions in the internal functions.
Fixed getStartOfMonth
which returned wrong value when the second argument is passed
and the difference between the current and the desired month is not equal to 0.
Added alternative functions to deal with both full and calendar days, months, years.
Removed getWeek
function.
Colsult the migration guide for more.
Fixed rounding issues for negative values in getDiffInDays
, getDiffInHours
& getDiffInMinutes
.
Fixed getRelativeDate
return value for dates related to February.
Also fixed several security vulnerabilities.
Improved typings for getWeekdayName
and getMonthName
.
Dropped Node.js 12 support.
Added token ZZ
to formatDate
.
Improved formatDate
for older browsers.
Fixed several security vulnerabilities:
-
Prototype Pollution in ini. Updated from 1.3.5 to 1.3.8.
-
Prototype Pollution in y18n. Updated from 4.0.0 to 4.0.1.
-
Use of a Broken or Risky Cryptographic Algorithm in elliptic. Updated from 6.5.3 to 6.5.4.
-
Regular Expression Denial of Service in hosted-git-info. Updated from 2.8.8 to 2.8.9.
-
Command Injection in lodash. Updated from 4.17.20 to 4.17.21.
-
Regular Expression Denial of Service in glob-parent. Updated from 5.1.1 to 5.1.2. Also led to nodemon update from 1.19.4 to 2.0.7.
Removed @funboxteam/diamonds from the deps. Instead we inlined
the only one fn used — getPlural
in getRelativeDate
.
Rewrote subtract*
functions using add*
functions. It has led to decreasing
the total size of the lib.
Added types
field into package.json to fix tsc
errors and improve IDE's
autocomplete.
Breaking change: getTime
has been renamed to getUnixTimestamp
. The function's param type definition has been updated too.
Prepared the package for publishing on GitHub. Updated all the deps, added tests coverage & improved tests.
Fixed formatTimeString
hour formatting (H
).
Check out the migration guide.
Removed core-js from peer dependencies.
Improved types declaration.
The package has been rewritten to TypeScript.
Also formatTime
has been renamed to formatTimeString
.
Check out the migration guide.
Added polyfills.
Fixed getEndOfMonth
. Earlier it might return incorrect value when it was fired
with diff
param passed.
Made format
param of parseDate
optional. When it is not passed
it the function tries to parse the passed string using Date.parse
.
Fixed getRelativeDate
several years interval calculation.
Fixed HH
value calculation in formatDate
. Earlier it returned 24
instead of 00
for the beginning of a day.
Added MMM
template into formatDate
, which allows to add
short month name into the result string (e.g. янв.
).
Added Z
template into formatDate
supported templates list, which allows to add
timezone offset into the result string (it's formatted as ±HH:mm
).
Fixed getUtcOffset
. Earlier it returned only positive values.
Fixed getRelativeDate
. Now if the returned entity is the only one,
there won't be a number in returned string. E.g. минуту назад
instead of 1 минуту назад
.
Added getTimezoneName
. It returns timezone name (e.g. Europe/Moscow
)
using Intl API when it's possible. If it's not then fallback value returned.
The list of fallback values contains integer offsets only.
So, if there's a user from Colombo (Shi Lanka) with modern browser,
Asia/Colombo
will be returned (+05:30). But if they use IE 11, then Asia/Yekaterinburg
will be returned (+05:00). More precise values aren't used to prevent the lib bloating.
But may be added in future.
Add second param (format
) to getMonthName
and getWeekdayName
.
It may has two values: long
or short
like those that used
in Date.prototype.toLocaleString()
in options.month
and options.weekday
accordingly.
Add many new functions:
addHours
;addMinutes
;getEndOfHours
;getEndOfMinutes
;getHours
;getMinutes
;getStartOfHours
;getStartOfMinutes
;getWeek
;isSameHour
;isSameMinute
;subtractHours
;subtractMinutes
.
Added getRelativeDate
& getDiffInHours
.
Fixed formatDate
for IE 11 and old Edges.
Added new functions:
getStartOfWeek
;getEndOfWeek
;formatTime
;isTimeValid
;parseDate
.
Also added seconds to the object returned by getDuration
.
Fixed hours formatting in formatDate
(sometimes HH
returned one digit instead of two),
and values rounding in getDiffInDays
& getDiffInMinutes
.
Replaced Number.isNaN
with isNaN
, because the first one doesn't work in IE11.
Added the possibility to pass Unix Timestamp as a string to every function that accepts date.
Added new two functions: getStartOfDecade
and getEndOfDecade
.
Renamed functions getDiffOf*
to getDiffIn*
(e.g. there was getDiffOfMinutes
,
and now it's getDiffInMinutes
). It's a breaking change, but the library isn't used anywhere,
so we're not releasing a major version.
Added flag files
into package.json, to prevent useless files from putting into npm-package.
Removed flag private: true
from package.json, to make it possible to publish the package.
Initial version.