Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade date-fns to 2.30.0 #2730

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .bundlemonrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"maxPercentIncrease": 10
},
{
"path": "transpiled/react/stylesheet.css",
"maxPercentIncrease": 10
"path": "transpiled/react/stylesheet.css"
}
],
"groups": [
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup_modules
- uses: ./.github/actions/build_cache_read
- name: Tests
run: yarn test
- name: BundleMon
uses: lironer/bundlemon-action@v1
- name: Tests
run: yarn test
argosDesktop:
needs: [prepareArgos, build]
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"chart.js": "3.7.1",
"classnames": "^2.2.5",
"cozy-interapp": "^0.5.4",
"date-fns": "^1.28.5",
"date-fns": "2.30.0",
"filesize": "8.0.7",
"hammerjs": "^2.0.8",
"intersection-observer": "0.11.0",
Expand Down
2 changes: 1 addition & 1 deletion react/BarContextProvider/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DumbHelloWorld = translate()(({ t, f, lang }) => (
<div>
{t('helloworld')}
<br />
{f('2020-01-06', 'DDD MMM')}
{f('2020-01-06', 'D LLL', { useAdditionalDayOfYearTokens: true })}
<br />
{lang}
</div>
Expand Down
6 changes: 3 additions & 3 deletions react/DateMonthPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const MonthButton = ({ monthNum, onClick, isSelected }) => {
)}
onClick={handleClick}
>
{f(d, 'MMM')}
{f(d, 'LLL')}
</button>
)
}
Expand All @@ -50,7 +50,7 @@ const DateMonthPicker = ({ initialValue, onSelect }) => {

const handleClickMonth = month => {
const d = new Date(year, month, 1)
onSelect(format(d, 'YYYY-MM-DD'))
onSelect(format(d, 'yyyy-LL-dd'))
}
return (
<div>
Expand Down Expand Up @@ -93,7 +93,7 @@ const dateMonthProp = function (props, propName, componentName) {
'` supplied to' +
' `' +
componentName +
'`. Should be in the form YYYY-MM.'
'`. Should be in the form yyyy-LL.'
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion react/FilePicker/FilePickerBodyItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const FilePickerBodyItem = ({
const Input = multiple ? Checkbox : Radio

const listItemSecondaryContent = isFile(item)
? `${f(item.updated_at, 'DD MMM YYYY')} - ${filesize(item.size, {
? `${f(item.updated_at, 'dd LLL yyyy')} - ${filesize(item.size, {
base: 10
})}`
: null
Expand Down
2 changes: 1 addition & 1 deletion react/ListItem/ListItemFile/SecondaryText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const SecondaryText = ({ secondary, file }) => {
if (secondary) return secondary

const date = file?.metadata?.datetime
? f(file?.metadata?.datetime, 'DD/MM/YYYY')
? f(file?.metadata?.datetime, 'dd/LL/yyyy')
: null

return (
Expand Down
13 changes: 8 additions & 5 deletions react/providers/I18n/format.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'
import format from 'date-fns/format'
import formatDistanceToNow from 'date-fns/formatDistanceToNow'

import { DEFAULT_LANG } from '.'

Expand Down Expand Up @@ -29,10 +29,13 @@ export const provideDateFnsLocale = (userLang, defaultLang = DEFAULT_LANG) => {

export const initFormat =
(userLang, defaultLang = DEFAULT_LANG) =>
(date, formatStr) => {
(date, formatStr, opts = {}) => {
const locale = provideDateFnsLocale(userLang, defaultLang)
return format(date, formatStr, { locale })
const ensureDate = date && typeof date === 'string' ? new Date(date) : date

return format(ensureDate, formatStr, { locale, ...opts })
}

export const formatLocallyDistanceToNow = date =>
distanceInWordsToNow(date, { locale: locales[lang] })
export const formatLocallyDistanceToNow = date => {
return formatDistanceToNow(date, { locale: locales[lang] })
}
2 changes: 1 addition & 1 deletion react/providers/I18n/index.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const DumbI18nHelloWorld = ({ t, f, lang }) => (
<div>
{t('helloworld')}
<br />
{f('2020-01-06', 'DDD MMM')}
{f('2020-01-06', 'D LLL', { useAdditionalDayOfYearTokens: true })}
<br />
{lang}
</div>
Expand Down
22 changes: 18 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,13 @@
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.21.0":
version "7.26.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.9.2":
version "7.14.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.6.tgz#535203bc0892efc7dec60bdc27b2ecf6e409062d"
Expand Down Expand Up @@ -6548,10 +6555,12 @@ [email protected]:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==

date-fns@^1.28.5:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==
[email protected]:
version "2.30.0"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0"
integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==
dependencies:
"@babel/runtime" "^7.21.0"

date-now@^0.1.4:
version "0.1.4"
Expand Down Expand Up @@ -16623,6 +16632,11 @@ regenerator-runtime@^0.13.4:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz#e96bf612a3362d12bb69f7e8f74ffeab25c7ac91"
integrity sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==

regenerator-runtime@^0.14.0:
version "0.14.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==

regenerator-transform@^0.14.2:
version "0.14.5"
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4"
Expand Down
Loading