Skip to content

Commit

Permalink
feat(date-fns): we update date-fns to version v2.0.0
Browse files Browse the repository at this point in the history
affects: @datepicker-react/hooks, @datepicker-react/styled

Because we updated date-fns to v2.0.0, we need to make some breaking changes:
Date format: we use
date-fns v2.0.0 date format
Hooks: parseDate function: The function takes an additional parameter,
namely a date.

BREAKING CHANGE:
date format, parseDate

ISSUES CLOSED: #4
  • Loading branch information
tresko committed Aug 23, 2019
1 parent c80fed1 commit 38d961e
Show file tree
Hide file tree
Showing 57 changed files with 11,992 additions and 4,861 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"extensions": [".js", ".tsx", ".ts"]
}
],
"import/no-unresolved": ["error", {"ignore": ["^react$", "csstype"]}]
"import/no-unresolved": ["error", {"ignore": ["^react$", "csstype"]}],
"@typescript-eslint/no-angle-bracket-type-assertion": 0
},
"settings": {
"import/resolver": {
Expand Down
43 changes: 43 additions & 0 deletions docs/migrating.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Migrating to 2.0.0

In version v2.0.0 we updated date-fns to 2.0.0. Therefore we need to make some breaking changes.

- **Date formatting** [All formats](https://date-fns.org/v2.0.0/docs/format),
[Popular mistakes](https://date-fns.org/v2.0.0/docs/Unicode-Tokens)

```js
// Before v2.0.0.
const dayLabelFormatFn = (date) => format(date, 'DD')
const weekdayLabelFormatFn = (date) => format(date, 'dd')
const monthLabelFormatFn = (date) => format(date, 'MMMM YYYY')

useMonth({
...,
dayLabelFormat = dayLabelFormatFn,
weekdayLabelFormat = weekdayLabelFormatFn,
monthLabelFormat = monthLabelFormatFn,
})

// v2.0.0.
const dayLabelFormatFn = (date) => format(date, 'dd')
const weekdayLabelFormatFn = (date) => format(date, 'eeeeee')
const monthLabelFormatFn = (date) => format(date, 'MMMM yyyy')

useMonth({
...,
dayLabelFormat = dayLabelFormatFn,
weekdayLabelFormat = weekdayLabelFormatFn,
monthLabelFormat = monthLabelFormatFn,
})
```

- **Hooks: parseDate function:** The function takes an additional parameter, namely a date.
[Docs](https://date-fns.org/v2.0.0/docs/parse)

```js
// Before v2.0.0
parseDate('02/11/2014', 'MM/dd/yyyy')

// v2.0.0
parseDate('02/11/2014', 'MM/dd/yyyy', new Date())
```
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"lerna:version-prerelease": "lerna version prerelease --github-release --conventional-commits",
"lerna:version-patch": "lerna version patch --github-release --conventional-commits",
"lerna:version-minor": "lerna version minor --github-release --conventional-commits",
"lerna:version-major": "lerna version major --github-release --conventional-commits",
"coveralls": "yarn run test:coverage && cat ./coverage/lcov.info | coveralls"
},
"author": "Miha Sedej",
Expand All @@ -63,15 +64,15 @@
"@types/storybook__addon-actions": "^3.4.3",
"@types/storybook__addon-knobs": "^5.0.3",
"@types/storybook__react": "^4.0.2",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.1-alpha.19",
"@typescript-eslint/parser": "^2.0.1-alpha.19",
"awesome-typescript-loader": "^5.2.1",
"babel-eslint": "^10.0.2",
"babel-loader": "^8.0.6",
"commitizen": "^4.0.3",
"coveralls": "^3.0.6",
"cz-lerna-changelog": "^2.0.2",
"date-fns": "^1.30.1",
"date-fns": "^2.0.0",
"eslint": "^6.2.1",
"eslint-config-prettier": "^6.1.0",
"eslint-config-react-app": "^5.0.1",
Expand Down Expand Up @@ -107,7 +108,7 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-typescript2": "^0.22.1",
"rollup-plugin-typescript2": "^0.23.0",
"rollup-plugin-visualizer": "^2.5.4",
"stylelint": "^10.1.0",
"stylelint-config-standard": "^18.3.0",
Expand Down
Loading

0 comments on commit 38d961e

Please sign in to comment.