Skip to content

Commit 10cf691

Browse files
committed
Fix async/await warning originating from datepickers, change ar date format
1 parent 0b601e1 commit 10cf691

File tree

19 files changed

+26
-28
lines changed

19 files changed

+26
-28
lines changed

src/components/DatePickerMixin.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ export default {
2626
return;
2727
}
2828
const options = (await import(`../locales/${locale}/datepicker.js`)).default;
29-
if (options.locale instanceof Promise) {
30-
this.datepickerLang = (await options.locale).default;
31-
}
32-
else {
33-
this.datepickerLang = options.locale;
34-
}
29+
this.datepickerLang = options.locale;
3530
this.dateFormat = options.dateFormat;
3631
this.timeFormat = options.timeFormat;
3732
this.dateTimeFormat = options.dateTimeFormat;

src/locales/ar/datepicker.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const format = 'YYYY-MM-DD';
2-
const locale = import('vue2-datepicker/locale/ar');
3-
(await locale).default.formatLocale.firstDayOfWeek = 1;
4-
export default {format, locale};
1+
// According to https://en.wikipedia.org/wiki/List_of_date_formats_by_country
2+
// many countries that use Arabic as their official language use the DD/MM/YYYY date format.
3+
const dateFormat = 'DD/MM/YYYY';
4+
const timeFormat = 'HH:mm:ss';
5+
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
6+
const locale = require('vue2-datepicker/locale/ar');
7+
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/de-CH/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const dateFormat = 'DD.MM.YYYY';
22
const timeFormat = 'H:mm:ss';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/de');
4+
const locale = require('vue2-datepicker/locale/de');
55
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/de/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const dateFormat = 'D.M.YYYY';
22
const timeFormat = 'H:mm:ss';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/de');
4+
const locale = require('vue2-datepicker/locale/de');
55
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/en-GB/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const dateFormat = 'DD/MM/YYYY';
22
const timeFormat = 'hh:mm:ss a';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/en');
4+
const locale = require('vue2-datepicker/locale/en');
55
locale.formatLocale.firstDayOfWeek = 1;
66
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/en-US/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const dateFormat = 'M/D/YYYY';
22
const timeFormat = 'hh:mm:ss a';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/en');
4+
const locale = require('vue2-datepicker/locale/en');
55
locale.formatLocale.firstDayOfWeek = 0;
66
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/en/datepicker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const timeFormat = 'HH:mm:ss';
44
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
55

66
// 2A. Either re-use settings and phrases from vue2-datepicker (and customize them)...
7-
const locale = import('vue2-datepicker/locale/en');
7+
const locale = require('vue2-datepicker/locale/en');
88

99
// Usually not needed, but we customize the first day of the week for "international" users.
10-
(await locale).default.formatLocale.firstDayOfWeek = 1;
10+
locale.formatLocale.firstDayOfWeek = 1;
1111

1212
// 2B. ... or define your own based on https://github.com/mengxiong10/vue2-datepicker
1313
/*

src/locales/es/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const dateFormat = 'DD/MM/YYYY';
22
const timeFormat = 'H:mm:ss';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/es');
4+
const locale = require('vue2-datepicker/locale/es');
55
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/fr-CA/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const dateFormat = 'YYYY-MM-DD';
22
const timeFormat = 'H:mm:ss';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/fr');
4+
const locale = require('vue2-datepicker/locale/fr');
55
export default {dateFormat, timeFormat, dateTimeFormat, locale};

src/locales/fr-CH/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const dateFormat = 'DD.MM.YYYY';
22
const timeFormat = 'H:mm:ss';
33
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
4-
const locale = import('vue2-datepicker/locale/fr');
4+
const locale = require('vue2-datepicker/locale/fr');
55
export default {dateFormat, timeFormat, dateTimeFormat, locale};

0 commit comments

Comments
 (0)