For some reason my datepicker has weeks beginning on Monday (MTWTFSS)
How do I get it to display beginning on Sunday (SMTWTFS)?
Week begins on... in datepicker
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Week begins on... in datepicker
In the app if you look under resources, there is a directory called datepicker. Not sure where is the function but I would start there. Might be wrong though. Let me know if you find anything and share.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Week begins on... in datepicker
I look there, and there are certainly some things having to do with setting the first day of the week, but I can't sort out how they work.
This is another of those preferences that it would be nice to be able to set in either the generator or the admin.
This is another of those preferences that it would be nice to be able to set in either the generator or the admin.
Re: Week begins on... in datepicker
From the plugin documentation here: http://freqdec.github.io/datePicker
Edit the appropriate xx.js language file in /resources/datepicker/js/lang to suit your requirementsThe “first day of the weekâ€
The first day of the week is stipulated within the downloaded language file (as logically, it’s a locale-specific setting). Should the language file not contain this setting, the first day of the week defaults to Monday.
Additionally, users can click on any of the day headers to dynamically set it as the first day of the week (or alternately, press the numbers 2-7 on the regular keyboard or numpad whenever the datepicker has keyboard focus).
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Week begins on... in datepicker
I'm thinking something else is in play. I edited en.js to force Sunday (0) and it still comes up as Monday.
The dynamic settings are convenient for some, I suppose, but I need it to come up "right" every time.
The dynamic settings are convenient for some, I suppose, but I need it to come up "right" every time.
Re: Week begins on... in datepicker
Yes, you are right. It's necessary to set first day of week in xx.js language file PLUS set your preferred language for the datepicker by loading the appropriate language .js file.
To set Sunday as first day of week and assuming your language is English:
In /resources/datepicker/js/lang/en.js remove the comments around firstDayOfWeek: and change the 0 to the desired day of the week (Sunday = 6), so you are just left with this:
Then set the locale for the datepicker by loading the edited en.js script to each page that uses the date picker by adding this:
You could add it to the rest of the <script> tags in header.php, to the top of the individual template files or even in hooks/header-extras.php works.
This is tested and works. You might need to clear your browser cache to see it immediately.
To set Sunday as first day of week and assuming your language is English:
In /resources/datepicker/js/lang/en.js remove the comments around firstDayOfWeek: and change the 0 to the desired day of the week (Sunday = 6), so you are just left with this:
Code: Select all
firstDayOfWeek:6,
Code: Select all
<script type="text/javascript" src="./resources/datepicker/js/lang/en.js"></script>
This is tested and works. You might need to clear your browser cache to see it immediately.
-
- AppGini Super Hero
- Posts: 336
- Joined: 2015-12-23 16:52
Re: Week begins on... in datepicker
Aha! I had found the first part, but didn't catch the second.
Applied (patch script against en.js, and modification to header-extras.php) and it works perfectly.
Thanks ever so much!
Applied (patch script against en.js, and modification to header-extras.php) and it works perfectly.
Thanks ever so much!