Skip to content

Commit

Permalink
fr, fr-CA and fr-CH locales TypeScript conversion (date-fns#2626)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fturmel authored Nov 29, 2021
1 parent 9c5299c commit a0406eb
Show file tree
Hide file tree
Showing 24 changed files with 422 additions and 821 deletions.
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import type { FormatLong } from '../../../types'
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index'

var dateFormats = {
const dateFormats = {
full: 'EEEE d MMMM y',
long: 'd MMMM y',
medium: 'd MMM y',
short: 'dd.MM.y'
short: 'yy-MM-dd',
}

var timeFormats = {
const timeFormats = {
full: 'HH:mm:ss zzzz',
long: 'HH:mm:ss z',
medium: 'HH:mm:ss',
short: 'HH:mm'
short: 'HH:mm',
}

var dateTimeFormats = {
const dateTimeFormats = {
full: "{{date}} 'à' {{time}}",
long: "{{date}} 'à' {{time}}",
medium: '{{date}}, {{time}}',
short: '{{date}}, {{time}}'
short: '{{date}}, {{time}}',
}

var formatLong = {
const formatLong: FormatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: 'full'
defaultWidth: 'full',
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: 'full'
defaultWidth: 'full',
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: 'full'
})
defaultWidth: 'full',
}),
}

export default formatLong
8 changes: 4 additions & 4 deletions src/locale/fr-CA/index.js → src/locale/fr-CA/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import formatDistance from '../fr/_lib/formatDistance/index'
import formatRelative from '../fr/_lib/formatRelative/index'
import localize from '../fr/_lib/localize/index'
import match from '../fr/_lib/match/index'

import type { Locale } from '../types'
// Unique for fr-CA
import formatLong from './_lib/formatLong/index'

Expand All @@ -17,7 +17,7 @@ import formatLong from './_lib/formatLong/index'
* @author François B [@fbonzon]{@link https://github.com/fbonzon}
* @author Gabriele Petrioli [@gpetrioli]{@link https://github.com/gpetrioli}
*/
var locale = {
const locale: Locale = {
code: 'fr-CA',
formatDistance: formatDistance,
formatLong: formatLong,
Expand All @@ -28,8 +28,8 @@ var locale = {
// Unique for fr-CA
options: {
weekStartsOn: 0 /* Sunday */,
firstWeekContainsDate: 1
}
firstWeekContainsDate: 1,
},
}

export default locale
16 changes: 8 additions & 8 deletions src/locale/fr-CA/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
| | | 0005-01-01T12:13:14.015Z | 5ème | 0004-12-26T00:00:00.000Z |
| Quarter (formatting) | Qo | 2019-01-01T12:13:14.015Z | 1er | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème | 2019-04-01T00:00:00.000Z |
| | QQQ | 2019-01-01T12:13:14.015Z | 1er trim. | Invalid Date |
| | | 2019-04-01T12:13:14.015Z | 2ème trim. | Invalid Date |
| | QQQ | 2019-01-01T12:13:14.015Z | 1er trim. | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème trim. | 2019-04-01T00:00:00.000Z |
| | QQQQ | 2019-01-01T12:13:14.015Z | 1er trimestre | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème trimestre | 2019-04-01T00:00:00.000Z |
| | QQQQQ | 2019-01-01T12:13:14.015Z | T1 | Invalid Date |
| | | 2019-04-01T12:13:14.015Z | T2 | Invalid Date |
| | QQQQQ | 2019-01-01T12:13:14.015Z | T1 | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | T2 | 2019-04-01T00:00:00.000Z |
| Quarter (stand-alone) | qo | 2019-01-01T12:13:14.015Z | 1er | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème | 2019-04-01T00:00:00.000Z |
| | qqq | 2019-01-01T12:13:14.015Z | 1er trim. | Invalid Date |
| | | 2019-04-01T12:13:14.015Z | 2ème trim. | Invalid Date |
| | qqq | 2019-01-01T12:13:14.015Z | 1er trim. | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème trim. | 2019-04-01T00:00:00.000Z |
| | qqqq | 2019-01-01T12:13:14.015Z | 1er trimestre | 2019-01-01T00:00:00.000Z |
| | | 2019-04-01T12:13:14.015Z | 2ème trimestre | 2019-04-01T00:00:00.000Z |
| Month (formatting) | Mo | 2019-02-11T12:13:14.015Z | 2ème | 2019-02-01T00:00:00.000Z |
Expand Down Expand Up @@ -156,9 +156,9 @@
| | | 2019-02-11T23:13:14.015Z | 11ème | 2019-02-11T23:00:00.000Z |
| Hour [1-24] | ko | 2019-02-11T11:13:14.015Z | 11ème | 2019-02-11T11:00:00.000Z |
| | | 2019-02-11T23:13:14.015Z | 23ème | 2019-02-11T23:00:00.000Z |
| Minute | mo | 2019-01-01T12:01:14.015Z | 1er | 2019-01-01T12:01:00.000Z |
| Minute | mo | 2019-01-01T12:01:14.015Z | 1ère | 2019-01-01T12:01:00.000Z |
| | | 2019-04-01T12:55:14.015Z | 55ème | 2019-04-01T12:55:00.000Z |
| Second | so | 2019-01-01T12:13:01.015Z | 1er | 2019-01-01T12:13:01.000Z |
| Second | so | 2019-01-01T12:13:01.015Z | 1ère | 2019-01-01T12:13:01.000Z |
| | | 2019-04-01T12:13:55.015Z | 55ème | 2019-04-01T12:13:55.000Z |
| Long localized date | P | 1987-02-11T12:13:14.015Z | 87-02-11 | 1987-02-11T00:00:00.000Z |
| | | 1453-05-29T23:59:59.999Z | 53-05-29 | 1453-05-29T00:00:00.000Z |
Expand Down
101 changes: 0 additions & 101 deletions src/locale/fr-CH/_lib/formatDistance/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import type { FormatLong } from '../../../types'
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index'

var dateFormats = {
const dateFormats = {
full: 'EEEE d MMMM y',
long: 'd MMMM y',
medium: 'd MMM y',
short: 'yy-MM-dd'
short: 'dd.MM.y',
}

var timeFormats = {
const timeFormats = {
full: 'HH:mm:ss zzzz',
long: 'HH:mm:ss z',
medium: 'HH:mm:ss',
short: 'HH:mm'
short: 'HH:mm',
}

var dateTimeFormats = {
const dateTimeFormats = {
full: "{{date}} 'à' {{time}}",
long: "{{date}} 'à' {{time}}",
medium: '{{date}}, {{time}}',
short: '{{date}}, {{time}}'
short: '{{date}}, {{time}}',
}

var formatLong = {
const formatLong: FormatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: 'full'
defaultWidth: 'full',
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: 'full'
defaultWidth: 'full',
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: 'full'
})
defaultWidth: 'full',
}),
}

export default formatLong
12 changes: 0 additions & 12 deletions src/locale/fr-CH/_lib/formatRelative/index.js

This file was deleted.

15 changes: 15 additions & 0 deletions src/locale/fr-CH/_lib/formatRelative/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { FormatRelativeFn } from '../../../types'

const formatRelativeLocale = {
lastWeek: "eeee 'la semaine dernière à' p",
yesterday: "'hier à' p",
today: "'aujourd’hui à' p",
tomorrow: "'demain à' p'",
nextWeek: "eeee 'la semaine prochaine à' p",
other: 'P',
}

const formatRelative: FormatRelativeFn = (token, _date, _baseDate, _options) =>
formatRelativeLocale[token]

export default formatRelative
17 changes: 0 additions & 17 deletions src/locale/fr-CH/_lib/formatters/index.js

This file was deleted.

Loading

0 comments on commit a0406eb

Please sign in to comment.