Skip to content

Commit

Permalink
Fix uk locale abbreviated months matcher (#3139)
Browse files Browse the repository at this point in the history
Fixed `uk` locale abbreviated months matcher.
  • Loading branch information
vadimpopa committed Aug 18, 2022
1 parent cbafa57 commit d9d5dd5
Show file tree
Hide file tree
Showing 3 changed files with 443 additions and 223 deletions.
@@ -1,218 +1,238 @@
const yearDates = [
new Date(1987, 1, 11, 12, 13, 14, 15),
new Date(0, 0, 1, 12, 13, 14, 15).setFullYear(5, 0, 1)
new Date(0, 0, 1, 12, 13, 14, 15).setFullYear(5, 0, 1),
]

const quarterDates = [
new Date(2019, 0, 1, 12, 13, 14, 15),
new Date(2019, 3, 1, 12, 13, 14, 15)
new Date(2019, 3, 1, 12, 13, 14, 15),
]

const monthDates = [
new Date(2019, 0, 11, 12, 13, 14, 15),
new Date(2019, 1, 11, 12, 13, 14, 15),
new Date(2019, 6, 10, 12, 13, 14, 15)
new Date(2019, 2, 11, 12, 13, 14, 15),
new Date(2019, 3, 10, 12, 13, 14, 15),
new Date(2019, 4, 10, 12, 13, 14, 15),
new Date(2019, 5, 10, 12, 13, 14, 15),
new Date(2019, 6, 10, 12, 13, 14, 15),
new Date(2019, 7, 10, 12, 13, 14, 15),
new Date(2019, 8, 10, 12, 13, 14, 15),
new Date(2019, 9, 10, 12, 13, 14, 15),
new Date(2019, 10, 10, 12, 13, 14, 15),
new Date(2019, 11, 10, 12, 13, 14, 15),
]

const weekOfYearDates = [
new Date(2019, 0, 1, 12, 13, 14, 15),
new Date(2019, 11, 1, 12, 13, 14, 15)
new Date(2019, 11, 1, 12, 13, 14, 15),
]

const dayOfMonthDates = [
new Date(2019, 1, 11, 12, 13, 14, 15),
new Date(2019, 1, 28, 12, 13, 14, 15)
new Date(2019, 1, 28, 12, 13, 14, 15),
]

const dayOfYearDates = [
new Date(2019, 1, 11, 12, 13, 14, 15),
new Date(2019, 11, 31, 12, 13, 14, 15)
new Date(2019, 11, 31, 12, 13, 14, 15),
]

const dayOfWeekDates = [
new Date(2019, 1, 11, 12, 13, 14, 15),
new Date(2019, 1, 15, 12, 13, 14, 15)
new Date(2019, 1, 15, 12, 13, 14, 15),
]

const timeOfDayDates = [
new Date(2019, 1, 11, 11, 13, 14, 15),
new Date(2019, 1, 11, 14, 13, 14, 15),
new Date(2019, 1, 11, 19, 13, 14, 15),
new Date(2019, 1, 11, 2, 13, 14, 15)
new Date(2019, 1, 11, 2, 13, 14, 15),
]

const hourDates = [
new Date(2019, 1, 11, 11, 13, 14, 15),
new Date(2019, 1, 11, 23, 13, 14, 15)
new Date(2019, 1, 11, 23, 13, 14, 15),
]

const localizedDates = [
new Date(1987, 0, 11, 12, 13, 14, 15),
new Date(1987, 1, 11, 12, 13, 14, 15),
new Date(1453, 4, 29, 23, 59, 59, 999)
new Date(1987, 2, 11, 12, 13, 14, 15),
new Date(1987, 3, 11, 12, 13, 14, 15),
new Date(1453, 4, 29, 23, 59, 59, 999),
new Date(1987, 5, 11, 12, 13, 14, 15),
new Date(1987, 6, 11, 12, 13, 14, 15),
new Date(1987, 7, 11, 12, 13, 14, 15),
new Date(1987, 8, 11, 12, 13, 14, 15),
new Date(1987, 9, 11, 12, 13, 14, 15),
new Date(1987, 10, 11, 12, 13, 14, 15),
new Date(1987, 11, 11, 12, 13, 14, 15),
]

const formatParseTokens = [
{
title: 'Calendar year',
tokens: ['yo'],
dates: yearDates
dates: yearDates,
},

{
title: 'Local week-numbering year',
tokens: ['Yo'],
dates: yearDates,
options: { useAdditionalWeekYearTokens: true }
options: { useAdditionalWeekYearTokens: true },
},

{
title: 'Quarter (formatting)',
tokens: ['Qo', 'QQQ', 'QQQQ', 'QQQQQ'],
dates: quarterDates
dates: quarterDates,
},

{
title: 'Quarter (stand-alone)',
tokens: ['qo', 'qqq', 'qqqq'],
dates: quarterDates
dates: quarterDates,
},

{
title: 'Month (formatting)',
tokens: ['Mo', 'MMM', 'MMMM', 'MMMMM'],
dates: monthDates
dates: monthDates,
},

{
title: 'Month (stand-alone) ',
tokens: ['Lo', 'LLL', 'LLLL', 'LLLLL'],
dates: monthDates
dates: monthDates,
},

{
title: 'Local week of year',
tokens: ['wo'],
dates: weekOfYearDates
dates: weekOfYearDates,
},

{
title: 'ISO week of year',
tokens: ['Io'],
dates: weekOfYearDates
dates: weekOfYearDates,
},

{
title: 'Day of month',
tokens: ['do'],
dates: dayOfMonthDates
dates: dayOfMonthDates,
},

{
title: 'Day of year',
tokens: ['Do'],
dates: dayOfYearDates,
options: { useAdditionalDayOfYearTokens: true }
options: { useAdditionalDayOfYearTokens: true },
},

{
title: 'Day of week (formatting)',
tokens: ['E', 'EE', 'EEE', 'EEEE', 'EEEEE', 'EEEEEE'],
dates: dayOfWeekDates
dates: dayOfWeekDates,
},

{
title: 'ISO day of week (formatting)',
tokens: ['io', 'iii', 'iiii', 'iiiii', 'iiiiii'],
dates: dayOfWeekDates
dates: dayOfWeekDates,
},

{
title: 'Local day of week (formatting)',
tokens: ['eo', 'eee', 'eeee', 'eeeee', 'eeeeee'],
dates: dayOfWeekDates
dates: dayOfWeekDates,
},

{
title: 'Local day of week (stand-alone)',
tokens: ['co', 'ccc', 'cccc', 'ccccc', 'cccccc'],
dates: dayOfWeekDates
dates: dayOfWeekDates,
},

{
title: 'AM, PM',
tokens: ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],
dates: timeOfDayDates
dates: timeOfDayDates,
},

{
title: 'AM, PM, noon, midnight',
tokens: ['b', 'bb', 'bbb', 'bbbb', 'bbbbb'],
dates: timeOfDayDates
dates: timeOfDayDates,
},

{
title: 'Flexible day period',
tokens: ['B', 'BB', 'BBB', 'BBBB', 'BBBBB'],
dates: timeOfDayDates
dates: timeOfDayDates,
},

{
title: 'Hour [1-12]',
tokens: ['ho'],
dates: hourDates
dates: hourDates,
},

{
title: 'Hour [0-23]',
tokens: ['Ho'],
dates: hourDates
dates: hourDates,
},

{
title: 'Hour [0-11]',
tokens: ['Ko'],
dates: hourDates
dates: hourDates,
},

{
title: 'Hour [1-24]',
tokens: ['ko'],
dates: hourDates
dates: hourDates,
},

{
title: 'Minute',
tokens: ['mo'],
dates: [
new Date(2019, 0, 1, 12, 1, 14, 15),
new Date(2019, 3, 1, 12, 55, 14, 15)
]
new Date(2019, 3, 1, 12, 55, 14, 15),
],
},

{
title: 'Second',
tokens: ['so'],
dates: [
new Date(2019, 0, 1, 12, 13, 1, 15),
new Date(2019, 3, 1, 12, 13, 55, 15)
]
new Date(2019, 3, 1, 12, 13, 55, 15),
],
},

{
title: 'Long localized date',
tokens: ['P', 'PP', 'PPP', 'PPPP'],
dates: localizedDates
dates: localizedDates,
},

{
title: 'Long localized time',
tokens: ['p', 'pp', 'ppp', 'pppp'],
dates: localizedDates
dates: localizedDates,
},

{
title: 'Combination of date and time',
tokens: ['Pp', 'PPpp', 'PPPppp', 'PPPPpppp'],
dates: localizedDates
}
dates: localizedDates,
},
]
export default formatParseTokens
4 changes: 2 additions & 2 deletions src/locale/uk/_lib/match/index.ts
Expand Up @@ -28,8 +28,8 @@ const parseQuarterPatterns = {

const matchMonthPatterns = {
narrow: /^[слбктчвжг]/i,
abbreviated: /^(січ|лют|бер|берез|кві|трав?|чер|лип|сер|вер|жов|лис(топ)?|груд)\.?/i,
wide: /^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопада?|грудень|грудня)/i,
abbreviated: /^(січ|лют|бер(ез)?|квіт|трав|черв|лип|серп|вер(ес)?|жовт|лис(топ)?|груд)\.?/i,
wide: /^(січень|січня|лютий|лютого|березень|березня|квітень|квітня|травень|травня|червня|червень|липень|липня|серпень|серпня|вересень|вересня|жовтень|жовтня|листопад[а]?|грудень|грудня)/i,
}

const parseMonthPatterns = {
Expand Down

0 comments on commit d9d5dd5

Please sign in to comment.