Cant seem to update locale properties globally nor locally
Describe the bug
The locale doesn't seem to change when i update it.
All i want is for the isoWeek to start from a sunday. But i cant seem to change the local to help me...
ref #215
Expected behavior
The local object to change to show the changes made to it.
And after the change for the isoWeek to return the proper week according to the change to make it start from sundays.
ex: "2023/2/19" has to be week 8 but is 7
Information
-
Day.js Version :
"dayjs": "^1.11.7", -
OS: Artix Linux
-
Browser : Mozilla Firefox 110.0
-
Time zone: Europe/Athens
var en = require('dayjs/locale/en');
console.log(en);
/*
{
"name": "en",
"weekdays": [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
"months": [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
}
*/
var updateLocale = require('dayjs/plugin/updateLocale')
dayjs.extend(updateLocale)
dayjs.updateLocale('en', {
weekStart: 1,
})
console.log(en);
/*
{
"name": "en",
"weekdays": [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
"months": [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
}
*/
en = require('dayjs/locale/en');
console.log(en);
/*
{
"name": "en",
"weekdays": [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
"months": [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
}
*/
@LamprosPitsillos , hello. As I understand, dayjs doesn't mutate original locale data. You can check actual locale data by
dayjs.Ls[dayjs.locale()]
About isoWeek - it always starts on Monday by standard, so not depends on weekStart. Maybe you need the week method.
@Eternal-Rise I am running
import dayjs from 'dayjs';
import en from 'dayjs/locale/en';
dayjs.locale({
...en,
weekStart: 1,
});
and I still see this:
{
name: 'en-au',
weekdays: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
],
months: [
'January', 'February',
'March', 'April',
'May', 'June',
'July', 'August',
'September', 'October',
'November', 'December'
],
weekStart: 1,
weekdaysShort: [
'Sun', 'Mon',
'Tue', 'Wed',
'Thu', 'Fri',
'Sat'
],
monthsShort: [
'Jan', 'Feb', 'Mar',
'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'
],
weekdaysMin: [
'Su', 'Mo',
'Tu', 'We',
'Th', 'Fr',
'Sa'
],
ordinal: [Function: ordinal],
formats: {
LT: 'h:mm A',
LTS: 'h:mm:ss A',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY h:mm A',
LLLL: 'dddd, D MMMM YYYY h:mm A'
},
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
}
}
and this date 2023-11-22 is day number 3 (dayjs(index).day()) but is should be 2 if we start week on a Monday (1).
I dont understand why this is not updating. Do you have a suggestion?
Goal is: Start of week Monday, day of Week for Wednesday would be 2.