Skip to content

Commit 3426089

Browse files
author
Nathan Reyes
committed
Fix month formatting bug in Safari
1 parent 39d03f3 commit 3426089

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/components/CalendarPane.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export default {
390390
const key = `${year.toString()}.${month.toString()}`;
391391
let page = this.pages.find(p => (p.key === key));
392392
if (!page) {
393-
const date = new Date(year, month - 1, 1);
393+
const date = new Date(year, month - 1, 15);
394394
const monthComps = getMonthComps(month, year);
395395
const prevMonthComps = getPrevMonthComps(month, year);
396396
const nextMonthComps = getNextMonthComps(month, year);

src/utils/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const todayComps = {
1515
export const getMonthDates = (year = 2000) => {
1616
const dates = [];
1717
for (let i = 0; i < 12; i++) {
18-
dates.push(new Date(year, i, 1));
18+
dates.push(new Date(year, i, 15));
1919
}
2020
return dates;
2121
};

src/utils/locales.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const locales = {
99
// Catalan
1010
ca: { dow: 2, L: 'DD/MM/YYYY' },
1111
// Chinese (China)
12-
'zh-cn': { dow: 2, L: 'YYYY/MM/DD' },
12+
'zh-CN': { dow: 2, L: 'YYYY/MM/DD' },
1313
// Chinese (Taiwan)
14-
'zh-tw': { L: 'YYYY/MM/DD' },
14+
'zh-TW': { L: 'YYYY/MM/DD' },
1515
// Croatian
1616
hr: { dow: 2, L: 'DD.MM.YYYY' },
1717
// Czech
@@ -21,27 +21,27 @@ const locales = {
2121
// Dutch
2222
nl: { dow: 2, L: 'DD.MM.YYYY' },
2323
// English (US)
24-
'en-us': { L: 'MM/DD/YYYY' },
24+
'en-US': { L: 'MM/DD/YYYY' },
2525
// English (Australia)
26-
'en-au': { dow: 2, L: 'DD/MM/YYYY' },
26+
'en-AU': { dow: 2, L: 'DD/MM/YYYY' },
2727
// English (Canada)
28-
'en-ca': { L: 'YYYY-MM-DD' },
28+
'en-CA': { L: 'YYYY-MM-DD' },
2929
// English (Great Britain)
30-
'en-gb': { dow: 2, L: 'DD/MM/YYYY' },
30+
'en-GB': { dow: 2, L: 'DD/MM/YYYY' },
3131
// English (Ireland)
32-
'en-ie': { dow: 2, L: 'DD-MM-YYYY' },
32+
'en-IE': { dow: 2, L: 'DD-MM-YYYY' },
3333
// English (New Zealand)
34-
'en-nz': { dow: 2, L: 'DD/MM/YYYY' },
34+
'en-NZ': { dow: 2, L: 'DD/MM/YYYY' },
3535
// Esperanto
3636
eo: { dow: 2, L: 'YYYY-MM-DD' },
3737
// Finnish
3838
fi: { dow: 2, L: 'Do MMMM[ta] YYYY' },
3939
// French
4040
fr: { dow: 2, L: 'DD/MM/YYYY' },
4141
// French (Canada)
42-
'fr-ca': { L: 'YYYY-MM-DD' },
42+
'fr-CA': { L: 'YYYY-MM-DD' },
4343
// French (Switzerland)
44-
'fr-ch': { dow: 2, L: 'DD.MM.YYYY' },
44+
'fr-CH': { dow: 2, L: 'DD.MM.YYYY' },
4545
// German
4646
de: { dow: 2, L: 'DD.MM.YYYY' },
4747
// Indonesian
@@ -73,8 +73,8 @@ const locales = {
7373
// Turkish
7474
tk: { dow: 2, L: 'DD.MM.YYYY' },
7575
};
76-
locales.en = locales['en-us'];
77-
locales.zh = locales['zh-cn'];
76+
locales.en = locales['en-US'];
77+
locales.zh = locales['zh-CN'];
7878

7979
// Month and day names are derived from Intl.DateTimeFormat
8080
const getMonthNames = (locale, length) => {
@@ -88,7 +88,7 @@ const getDayNames = (locale, length) => {
8888

8989
export default (locale, defaults) => {
9090
locale = locale || new Intl.DateTimeFormat().resolvedOptions().locale;
91-
const searchLocales = [locale.toLowerCase(), locale.toLowerCase().substring(0, 2), 'en-us'];
91+
const searchLocales = [locale, locale.substring(0, 2), 'en-US'];
9292
const matchKey = searchLocales.find(l => locales[l]);
9393
const matchValue = locales[matchKey];
9494
defaults.locale = matchKey;

0 commit comments

Comments
 (0)