|
1 | 1 | export default (o, c, dayjs) => { // locale needed later
|
2 | 2 | const proto = c.prototype
|
3 | 3 | const getLocalePart = part => (part && (part.indexOf ? part : part.s))
|
4 |
| - const getShort = (ins, target, full, num) => { |
| 4 | + const getShort = (ins, target, full, num, localeOrder) => { |
5 | 5 | const locale = ins.name ? ins : ins.$locale()
|
6 | 6 | const targetLocale = getLocalePart(locale[target])
|
7 | 7 | const fullLocale = getLocalePart(locale[full])
|
8 |
| - return targetLocale || fullLocale.map(f => f.substr(0, num)) |
| 8 | + const result = targetLocale || fullLocale.map(f => f.substr(0, num)) |
| 9 | + if (!localeOrder) return result |
| 10 | + const { weekStart } = locale || 0 |
| 11 | + return result.map((_, index) => (result[(index + weekStart) % 7])) |
9 | 12 | }
|
10 | 13 | const getDayjsLocaleObject = () => dayjs.Ls[dayjs.locale()]
|
11 | 14 | const localeData = function () {
|
@@ -42,9 +45,9 @@ export default (o, c, dayjs) => { // locale needed later
|
42 | 45 |
|
43 | 46 | dayjs.monthsShort = () => getShort(getDayjsLocaleObject(), 'monthsShort', 'months', 3)
|
44 | 47 |
|
45 |
| - dayjs.weekdays = () => getDayjsLocaleObject().weekdays |
| 48 | + dayjs.weekdays = localeOrder => getShort(getDayjsLocaleObject(), 'weekdays', null, null, localeOrder) |
46 | 49 |
|
47 |
| - dayjs.weekdaysShort = () => getShort(getDayjsLocaleObject(), 'weekdaysShort', 'weekdays', 3) |
| 50 | + dayjs.weekdaysShort = localeOrder => getShort(getDayjsLocaleObject(), 'weekdaysShort', 'weekdays', 3, localeOrder) |
48 | 51 |
|
49 |
| - dayjs.weekdaysMin = () => getShort(getDayjsLocaleObject(), 'weekdaysMin', 'weekdays', 2) |
| 52 | + dayjs.weekdaysMin = localeOrder => getShort(getDayjsLocaleObject(), 'weekdaysMin', 'weekdays', 2, localeOrder) |
50 | 53 | }
|
0 commit comments