Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: date-fns/date-fns
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.26.0
Choose a base ref
...
head repository: date-fns/date-fns
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.27.0
Choose a head ref

Commits on Nov 19, 2021

  1. Copy the full SHA
    653f97b View commit details
  2. Add the release doc

    kossnocorp committed Nov 19, 2021
    Copy the full SHA
    9057eee View commit details

Commits on Nov 21, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8dd989f View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e1cc0f View commit details

Commits on Nov 23, 2021

  1. Update release.md (#2778)

    fishmandev authored Nov 23, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    90ed1eb View commit details

Commits on Nov 24, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    191e846 View commit details
  2. Fix flow types for closestTo and closestIndexTo (#2781)

    Fixed flow types for closestTo and closestIndexTo.
    leshakoss authored Nov 24, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fc6df5f View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7add27a View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d81cb0e View commit details
  5. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4508953 View commit details
  6. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7df7faa View commit details
  7. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    63dada0 View commit details
  8. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b8d6779 View commit details
  9. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7800f00 View commit details
  10. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    508c1d5 View commit details

Commits on Nov 25, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    846b707 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3a8c0e3 View commit details
  3. Fix eachMinuteOfInterval interval validation (#2603)

    Fixed `eachMinuteOfInterval` not handling intervals less than a minute correctly.
    nodeadtree authored Nov 25, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ec0479d View commit details

Commits on Nov 28, 2021

  1. Migrate tr locale (#2720)

    Fixed translation for Monday in Turkish locale.
    bulutfatih authored Nov 28, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fa65963 View commit details
  2. Add Khmer(km) Locale Support (#2713)

    Added Khmer locale (`km`).
    seanghay authored Nov 28, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    66606e3 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1f4e494 View commit details

Commits on Nov 29, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c2ef296 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    52c2f94 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fab57a9 View commit details
  4. Fix constants typings (#2791)

    Fixed constants not having proper TypeScript and Flow types.
    JuanM04 authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9c5299c View commit details
  5. fr, fr-CA and fr-CH locales TypeScript conversion (#2626)

    Fixed ordinal formatting for years, weeks, hours, minutes and seconds in `fr`, `fr-CA` and `fr-CH` locales.
    Fixed parser errors for `QQQ`, `QQQQQ` and `qqq` tokens in `fr`, `fr-CA` and `fr-CH` locales.
    fturmel authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a0406eb View commit details
  6. Fix the format of zeros in formatDuration in Czech locale (#2579)

    Fixed the format of zeros in `formatDuration` in Czech locale.
    janziemba authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b13edd6 View commit details
  7. Fix Estonian date patterns (#2038)

    Fixed regular expressions for `parse` in Estonian locale.
    pgcalixto authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    95a978b View commit details
  8. [i18n]: replace LT -> p, L -> P in ar, fil, ka locales (#2797)

    Fixed `formatRelative` patterns in Georgian locale.
    leshakoss authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    905ab37 View commit details
  9. correct some words translations (#1632)

    Fixed era and month formatters in Azerbaijani locale (`az`).
    Haqverdi authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    699d1af View commit details
  10. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    92b0253 View commit details
  11. Fix short date separator for Romanian locale (#2213)

    Fixed `P` token in `format` for Romanian locale (`ro`).
    razvanmitre authored Nov 29, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cf06940 View commit details
  12. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    75eb760 View commit details

Commits on Nov 30, 2021

  1. fix(locale): fix zhCN quarter translation (#2771)

    Fixed translation for quarters in `format`  in Chinese Simplified locale (`zh-CN`).
    07akioni authored Nov 30, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    258845b View commit details
  2. Update snapshots

    leshakoss committed Nov 30, 2021
    Copy the full SHA
    4f33a51 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c374b3c View commit details
  4. Regenerate types

    leshakoss committed Nov 30, 2021
    Copy the full SHA
    7e0d8cf View commit details
  5. Copy the full SHA
    ea86a82 View commit details
Showing with 2,888 additions and 1,940 deletions.
  1. +4 −1 .github/workflows/coverage.yaml
  2. +60 −0 CHANGELOG.md
  3. +10 −10 docs/i18nContributionGuide.md
  4. +19 −0 docs/release.md
  5. +25 −12 scripts/build/_lib/typings/common.js
  6. +8 −4 scripts/build/_lib/typings/flow.js
  7. +67 −68 src/_lib/format/formatters/index.js
  8. +11 −9 src/_lib/format/longFormatters/{index.js → index.ts}
  9. +8 −8 src/_lib/getUTCISOWeekYear/{index.js → index.ts}
  10. +0 −36 src/_lib/getUTCISOWeekYear/test.js
  11. +36 −0 src/_lib/getUTCISOWeekYear/test.ts
  12. +22 −14 src/_lib/getUTCWeekYear/{index.js → index.ts}
  13. +0 −70 src/_lib/getUTCWeekYear/test.js
  14. +71 −0 src/_lib/getUTCWeekYear/test.ts
  15. +18 −13 src/_lib/setUTCDay/{index.js → index.ts}
  16. +0 −132 src/_lib/setUTCDay/test.js
  17. +139 −0 src/_lib/setUTCDay/test.ts
  18. +12 −10 src/_lib/setUTCISODay/{index.js → index.ts}
  19. +0 −79 src/_lib/setUTCISODay/test.js
  20. +84 −0 src/_lib/setUTCISODay/test.ts
  21. +14 −10 src/_lib/startOfUTCWeek/{index.js → index.ts}
  22. +0 −108 src/_lib/startOfUTCWeek/test.js
  23. +119 −0 src/_lib/startOfUTCWeek/test.ts
  24. +19 −11 src/_lib/startOfUTCWeekYear/{index.js → index.ts}
  25. +0 −95 src/_lib/startOfUTCWeekYear/test.js
  26. +98 −0 src/_lib/startOfUTCWeekYear/test.ts
  27. +19 −12 src/addBusinessDays/test.ts
  28. +1 −1 src/closestIndexTo/index.js.flow
  29. +1 −1 src/closestTo/index.js.flow
  30. +10 −0 src/constants/index.d.ts
  31. +10 −0 src/constants/index.js.flow
  32. +1 −1 src/eachMinuteOfInterval/index.ts
  33. +8 −0 src/eachMinuteOfInterval/test.ts
  34. +52 −0 src/format/test.js
  35. +16 −6 src/formatDuration/{index.js → index.ts}
  36. +10 −6 src/formatDuration/{test.js → test.ts}
  37. +19 −19 src/formatISO/{index.js → index.ts}
  38. +41 −17 src/formatISO/{test.js → test.ts}
  39. +15 −4 src/formatRFC3339/test.ts
  40. +1 −5 src/fp/closestIndexTo/index.js.flow
  41. +1 −5 src/fp/closestTo/index.js.flow
  42. +2 −6 src/fp/index.js.flow
  43. +2 −2 src/getWeek/index.ts
  44. +8 −0 src/getWeekOfMonth/test.js
  45. +2 −2 src/index.js.flow
  46. +30 −6 src/intervalToDuration/test.ts
  47. +5 −0 src/isSameMonth/index.ts
  48. +6 −0 src/lightFormat/test.ts
  49. +1 −1 src/locale/_lib/buildLocalizeFn/index.ts
  50. +4 −4 src/locale/az/_lib/localize/index.js
  51. +2 −2 src/locale/az/snapshot.md
  52. +1 −1 src/locale/cs/_lib/formatDistance/index.js
  53. +11 −11 src/locale/cs/snapshot.md
  54. +1 −1 src/locale/et/_lib/formatLong/index.js
  55. +6 −6 src/locale/et/_lib/match/index.js
  56. +27 −27 src/locale/et/snapshot.md
  57. +6 −6 src/locale/fil/_lib/formatRelative/index.js
  58. +12 −11 src/locale/{fr-CH/_lib/formatLong/index.js → fr-CA/_lib/formatLong/index.ts}
  59. +4 −4 src/locale/fr-CA/{index.js → index.ts}
  60. +35 −0 src/locale/fr-CA/index.ts.flow
  61. +8 −8 src/locale/fr-CA/snapshot.md
  62. +0 −101 src/locale/fr-CH/_lib/formatDistance/index.js
  63. +12 −11 src/locale/{fr/_lib/formatLong/index.js → fr-CH/_lib/formatLong/index.ts}
  64. +0 −12 src/locale/fr-CH/_lib/formatRelative/index.js
  65. +15 −0 src/locale/fr-CH/_lib/formatRelative/index.ts
  66. +0 −17 src/locale/fr-CH/_lib/formatters/index.js
  67. +0 −155 src/locale/fr-CH/_lib/localize/index.js
  68. +0 −137 src/locale/fr-CH/_lib/match/index.js
  69. +10 −8 src/locale/fr-CH/{index.js → index.ts}
  70. +35 −0 src/locale/fr-CH/index.ts.flow
  71. +8 −8 src/locale/fr-CH/snapshot.md
  72. +0 −101 src/locale/fr/_lib/formatDistance/index.js
  73. +106 −0 src/locale/fr/_lib/formatDistance/index.ts
  74. +12 −11 src/locale/{fr-CA/_lib/formatLong/index.js → fr/_lib/formatLong/index.ts}
  75. +0 −12 src/locale/fr/_lib/formatRelative/index.js
  76. +15 −0 src/locale/fr/_lib/formatRelative/index.ts
  77. +0 −17 src/locale/fr/_lib/formatters/index.js
  78. +0 −155 src/locale/fr/_lib/localize/index.js
  79. +157 −0 src/locale/fr/_lib/localize/index.ts
  80. +40 −42 src/locale/fr/_lib/match/{index.js → index.ts}
  81. +2 −2 src/locale/fr/{index.js → index.ts}
  82. +35 −0 src/locale/fr/index.ts.flow
  83. +8 −8 src/locale/fr/snapshot.md
  84. +1 −0 src/locale/index.js
  85. +1 −0 src/locale/index.js.flow
  86. +6 −6 src/locale/ka/_lib/formatRelative/index.js
  87. +9 −9 src/locale/ka/snapshot.md
  88. +44 −0 src/locale/km/_lib/formatDistance/index.ts
  89. +42 −0 src/locale/km/_lib/formatLong/index.ts
  90. +15 −0 src/locale/km/_lib/formatRelative/index.ts
  91. +184 −0 src/locale/km/_lib/localize/index.ts
  92. +138 −0 src/locale/km/_lib/match/index.ts
  93. +4 −0 src/locale/km/index.d.ts
  94. +35 −0 src/locale/km/index.js.flow
  95. +29 −0 src/locale/km/index.ts
  96. +35 −0 src/locale/km/index.ts.flow
  97. +304 −0 src/locale/km/snapshot.md
  98. +1 −1 src/locale/ro/_lib/formatLong/index.js
  99. +6 −6 src/locale/ro/snapshot.md
  100. +0 −101 src/locale/tr/_lib/formatDistance/index.js
  101. +112 −0 src/locale/tr/_lib/formatDistance/index.ts
  102. +12 −11 src/locale/tr/_lib/formatLong/{index.js → index.ts}
  103. +0 −12 src/locale/tr/_lib/formatRelative/index.js
  104. +15 −0 src/locale/tr/_lib/formatRelative/index.ts
  105. +45 −42 src/locale/tr/_lib/localize/{index.js → index.ts}
  106. +45 −45 src/locale/tr/_lib/match/{index.js → index.ts}
  107. +5 −3 src/locale/tr/{index.js → index.ts}
  108. +35 −0 src/locale/tr/index.ts.flow
  109. +6 −6 src/locale/tr/snapshot.md
  110. +14 −1 src/locale/types.ts
  111. +2 −2 src/locale/zh-CN/_lib/localize/index.js
  112. +8 −8 src/locale/zh-CN/snapshot.md
  113. +2 −3 src/nextFriday/index.ts
  114. +2 −3 src/nextMonday/index.ts
  115. +2 −3 src/nextSaturday/index.ts
  116. +2 −3 src/nextSunday/index.ts
  117. +2 −3 src/nextThursday/index.ts
  118. +2 −3 src/nextTuesday/index.ts
  119. +2 −3 src/nextWednesday/index.ts
  120. +8 −4 src/types.ts
  121. +36 −0 typings.d.ts
5 changes: 4 additions & 1 deletion .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ jobs:
matrix:
node-version: [14.x]

env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
@@ -25,5 +28,5 @@ jobs:
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Run release script
- name: Run coverage report
run: ./scripts/test/coverageReport.sh
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,66 @@ This change log follows the format documented in [Keep a CHANGELOG].
[semantic versioning]: http://semver.org/
[keep a changelog]: http://keepachangelog.com/

## v2.27.0 - 2021-11-30

Kudos to @tan75, @hg-pyun, @07akioni, @razvanmitre, @Haqverdi, @pgcalixto, @janziemba, @fturmel, @JuanM04, @zhirzh, @seanghay, @bulutfatih, @nodeadtree, @cHaLkdusT, @a-korzun, @fishmandev, @wingclover, @Zacharias3690, @kossnocorp and @leshakoss for working on the release.

### Fixed

- [Fixed translation for quarters in `format` in Chinese Simplified locale (`zh-CN`).](https://github.com/date-fns/date-fns/pull/2771)

- [Fixed `P` token in `format` for Romanian locale (`ro`).](https://github.com/date-fns/date-fns/pull/2213)

- [Fixed era and month formatters in Azerbaijani locale (`az`).](https://github.com/date-fns/date-fns/pull/1632)

- [Fixed `formatRelative` patterns in Georgian locale (`ka`).](https://github.com/date-fns/date-fns/pull/2797)

- [Fixed regular expressions for `parse` in Estonian locale (`er`).](https://github.com/date-fns/date-fns/pull/2038)

- [Fixed the format of zeros in `formatDuration` in Czech locale (`cs`).](https://github.com/date-fns/date-fns/pull/2579)

- [Fixed ordinal formatting for years, weeks, hours, minutes and seconds in `fr`, `fr-CA` and `fr-CH` locales.](https://github.com/date-fns/date-fns/pull/2626)

- [Fixed constants not having proper TypeScript and Flow types.](https://github.com/date-fns/date-fns/pull/2791)

- [Fixed translation for Monday in Turkish locale (`tr`).](https://github.com/date-fns/date-fns/pull/2720)

- [Fixed `eachMinuteOfInterval` not handling intervals less than a minute correctly.](https://github.com/date-fns/date-fns/pull/2603)

- [Fixed flow types for `closestTo` and `closestIndexTo`.](https://github.com/date-fns/date-fns/pull/2781)

### Added

- [Added Khmer locale (`km`).](https://github.com/date-fns/date-fns/pull/2713)

## v2.26.0 - 2021-11-19

Thanks to @kossnocorp, @leshakoss, @tan75, @gaplo, @AbdAllahAbdElFattah13, @fturmel, @kentaro84207, @V-Gutierrez, @atefBB, @jhonatanmacazana, @zhirzh, @Haqverdi, @mandaputtra, @micnic and @rikkalo for working on the release.

### Fixed

- [Fixed `formatRelative` format for `lastWeek` in Spanish locale.](https://github.com/date-fns/date-fns/pull/2753)

- [Fixed translation for October in Hindi locale.](https://github.com/date-fns/date-fns/pull/2729)

- [Fixed Azerbaijani locale to use correct era matchers for `parse`.](https://github.com/date-fns/date-fns/pull/1633)

- [Added the functions that use `weekStartsOn` and `firstWeekContainsDate` that were missing from the `Locale` documentation page.](https://github.com/date-fns/date-fns/pull/2652)

### Changed

- [Changed abbreviation for August from "Ags" to "Agt" in Indonesian locale.](https://github.com/date-fns/date-fns/pull/2658)

### Added

- [Added Irish English locale (`en-IE`).](https://github.com/date-fns/date-fns/pull/2772)

- [Added Arabic locale (`ar`).](https://github.com/date-fns/date-fns/pull/2721) ([#1670](https://github.com/date-fns/date-fns/issues/1670))

- [Added Hong Kong Traditional Chinese locale (zh-HK).](https://github.com/date-fns/date-fns/pull/2686) ([#2684](https://github.com/date-fns/date-fns/issues/2684))

- [Added Egyptian Arabic locale (ar-EG).](https://github.com/date-fns/date-fns/pull/2699)

## v2.25.0 - 2021-10-05

This release is brought to you by @kossnocorp, @gierschv, @fturmel, @redbmk, @mprovenc, @artyom-ivanov and @tan75.
20 changes: 10 additions & 10 deletions docs/i18nContributionGuide.md
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ Localizes a numeric era. Takes either 0 or 1 as the first argument.
As with many of the `localize` functions, they can be generated by built-in
`buildLocalizeFn` function.

From CLDR chart, use ['Date & Time'/'Gregorian'/'Eras'](https://www.unicode.org/cldr/charts/32/summary/en.html#1771) values.
From the CLDR chart, use ['Date & Time'/'Gregorian'/'Eras'](https://www.unicode.org/cldr/charts/32/summary/en.html#1771) values.

```js
// In `en-US` locale:
@@ -256,12 +256,12 @@ var result = locale.localize.era(1, {width: 'foobar'})

#### Formatting localizers

For some languages, there is a difference for "stand-alone" localizers and "formatting" localizers.
For some languages, there is a difference between "stand-alone" localizers and "formatting" localizers.
"Stand-alone" means that the resulting value should make grammatical sense without context.
"Formatting" means that the resulting value should be declined using the grammar rules of the language
as if the value was a part of a date.
For example, for languages with grammatical cases, stand-alone month could be in the nominative case ("January"),
and formatting month could decline as a part of phrase "1st of January".
For example, for languages with grammatical cases, the stand-alone month could be in the nominative case ("January"),
and the formatting month could decline as a part of the phrase "1st of January".
In this case, use parameters `formattingValues` and `defaultFormattingWidth` of `buildLocalizeFn` function.

Any localizer could be stand-alone and formatting.
@@ -303,7 +303,7 @@ export default localize

Localizes a quarter. Takes 1, 2, 3 or 4 as the first argument.
`width` could be either 'narrow', 'abbreviated' or 'wide'.
From CLDR chart, use ['Date & Time'/'Gregorian'/'Quarters'](https://www.unicode.org/cldr/charts/32/summary/en.html#1781) values.
From the CLDR chart, use ['Date & Time'/'Gregorian'/'Quarters'](https://www.unicode.org/cldr/charts/32/summary/en.html#1781) values.

```js
// In `en-US` locale:
@@ -337,7 +337,7 @@ Note the usage of `argumentCallback` here. It converts the value passed into `lo

Localizes a month. Takes numbers between 0 (for January) and 11 (for December).
`width` could be either 'narrow', 'abbreviated' or 'wide'.
From CLDR chart, use ['Date & Time'/'Gregorian'/'Months'](https://www.unicode.org/cldr/charts/32/summary/en.html#1793) values.
From the CLDR chart, use ['Date & Time'/'Gregorian'/'Months'](https://www.unicode.org/cldr/charts/32/summary/en.html#1793) values.

```js
// In `en-US` locale:
@@ -381,7 +381,7 @@ var monthValues = {

Localizes a week day. Takes numbers between 0 (for Sunday) and 6 (for Saturday).
`width` could be either 'narrow', 'short', 'abbreviated' or 'wide'.
From CLDR chart, use ['Date & Time'/'Gregorian'/'Days'](https://www.unicode.org/cldr/charts/32/summary/en.html#1829) values.
From the CLDR chart, use ['Date & Time'/'Gregorian'/'Days'](https://www.unicode.org/cldr/charts/32/summary/en.html#1829) values.

```js
// In `en-US` locale:
@@ -411,9 +411,9 @@ export default localize
#### localize.dayPeriod

Localizes a certain day period.
Could take of these strings as the argument: 'am', 'pm', 'midnight', 'noon', 'morning', 'afternoon', 'evening', 'night'.
Could take one of these strings as the argument: 'am', 'pm', 'midnight', 'noon', 'morning', 'afternoon', 'evening', 'night'.
`width` could be either 'narrow', 'abbreviated' or 'wide'.
From CLDR chart, use ['Date & Time'/'Gregorian'/'Day periods'](https://www.unicode.org/cldr/charts/32/summary/en.html#1857) values.
From the CLDR chart, use ['Date & Time'/'Gregorian'/'Day periods'](https://www.unicode.org/cldr/charts/32/summary/en.html#1857) values.

```js
// In `en-US` locale:
@@ -504,7 +504,7 @@ Use ordinal day of the month ('do' token) where applicable (date-fns, unlike CLD

`dateFormats.medium` contains the same values as `dateFormats.long`, but with short form of month and non-ordinal day.

`dateFormats.short` usually contains strictly numerical form of the date.
`dateFormats.short` usually contains a strictly numerical form of the date.
Pay attention to the order of units (big-, little- or middle-endian)

#### formatLong.timeFormats
19 changes: 19 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Releasing date-fns

1. First, make sure that the library is built by running `./scripts/build/build.sh` and committing and pushing any change you would have.

2. Then add the changelog entry generated by `yarn ts-node scripts/release/buildChangelog.ts` to (CHANGELOG.md)[../CHANGELOG.md]. Make sure that the output is valid Markdown and fix if there're any errors. Commit and push the file.

3. Using the version that the changelog script generated, run the command:

```bash
env VERSION="vX.XX.X" APP_ENV="production" GOOGLE_APPLICATION_CREDENTIALS="secrets/production/key.json" ./scripts/release/release.sh
```

The script will change `package.json`. **Do not commit the change, and reset it instead**.

4. Now when the package is published, go to [GitHub Releases](https://github.com/date-fns/date-fns/releases) and draft a new version using the changelog entry you generated earlier.

5. Finally, write an announce tweet using the created GitHub release as the tweet link.

You're done, great job!
37 changes: 25 additions & 12 deletions scripts/build/_lib/typings/common.js
Original file line number Diff line number Diff line change
@@ -15,13 +15,13 @@ function getParams(params, { leftBorder = '{', rightBorder = '}' } = {}) {
}

const formattedParams = addSeparator(
params.map(param => {
params.map((param) => {
const {
name,
props,
optional,
variable,
type: { names: typeNames }
type: { names: typeNames },
} = param
const type = getType(typeNames, { props, forceArray: variable })
return `${variable ? '...' : ''}${name}${optional ? '?' : ''}: ${type}`
@@ -36,8 +36,17 @@ function getParams(params, { leftBorder = '{', rightBorder = '}' } = {}) {
`
}

function getType(types, { props = [], forceArray = false } = {}) {
const typeStrings = types.map(type => {
function getType(
types,
{ props = [], forceArray = false, flowType = false } = {}
) {
let optional = false
if (flowType && types.some((type) => type === 'undefined')) {
optional = true
types = types.filter((type) => type !== 'undefined')
}

const typeStrings = types.map((type) => {
if (type === '*') {
return 'any'
}
@@ -63,23 +72,27 @@ function getType(types, { props = [], forceArray = false } = {}) {
return caseCorrectedType
})

const prefix = optional ? '?' : ''

const allArrayTypes =
typeStrings.length > 1 && typeStrings.every(type => type.endsWith('[]'))
typeStrings.length > 1 && typeStrings.every((type) => type.endsWith('[]'))
if (allArrayTypes) {
return `(${typeStrings.map(type => type.replace('[]', '')).join(' | ')})[]`
return `(${typeStrings
.map((type) => `${prefix}${type.replace('[]', '')}`)
.join(' | ')})[]`
}

return typeStrings.join(' | ')
return typeStrings.map((typeString) => `${prefix}${typeString}`).join(' | ')
}

function getFPFnType(params, returns) {
const fpParamTypes = params.map(param =>
getType(param.type.names, { props: param.props })
function getFPFnType(params, returns, { flowType = false } = {}) {
const fpParamTypes = params.map((param) =>
getType(param.type.names, { props: param.props, flowType })
)

const arity = fpParamTypes.length

fpParamTypes.push(getType(returns))
fpParamTypes.push(getType(returns, { flowType }))

return `CurriedFn${arity}<${fpParamTypes.join(', ')}>`
}
@@ -88,5 +101,5 @@ module.exports = {
correctTypeCase,
getParams,
getType,
getFPFnType
getFPFnType,
}
12 changes: 8 additions & 4 deletions scripts/build/_lib/typings/flow.js
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ function generateFlowFnTyping(fn, aliasDeclarations) {
const { title, args, content } = fn

const params = getParams(args, { leftBorder: '(', rightBorder: ')' })
const returns = getType(content.returns[0].type.names)
const returns = getType(content.returns[0].type.names, { flowType: true })

const moduleDeclaration = `declare module.exports: ${params} => ${returns}`

@@ -60,7 +60,7 @@ function generateFlowFnTyping(fn, aliasDeclarations) {
function generateFlowFnIndexTyping(fns, aliasDeclarations, constants) {
const fnsDeclarations = fns.map(({ title, args, content }) => {
const params = getParams(args, { leftBorder: '(', rightBorder: ')' })
const returns = getType(content.returns[0].type.names)
const returns = getType(content.returns[0].type.names, { flowType: true })
return `${title}: ${params} => ${returns}`
})

@@ -81,7 +81,9 @@ function generateFlowFnIndexTyping(fns, aliasDeclarations, constants) {
function generateFlowFPFnTyping(fn, aliasDeclarations) {
const { title, args, content } = fn

const type = getFPFnType(args, content.returns[0].type.names)
const type = getFPFnType(args, content.returns[0].type.names, {
flowType: true,
})

const typingFile = formatFlowFile`
${addSeparator(aliasDeclarations, '\n')}
@@ -97,7 +99,9 @@ function generateFlowFPFnTyping(fn, aliasDeclarations) {
function generateFlowFPFnIndexTyping(fns, aliasDeclarations, constants) {
const fnsDeclarations = fns.map(
({ title, args, content }) =>
`${title}: ${getFPFnType(args, content.returns[0].type.names)}`
`${title}: ${getFPFnType(args, content.returns[0].type.names, {
flowType: true,
})}`
)

const typingFile = formatFlowFile`
Loading