Week begins on... in datepicker

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Week begins on... in datepicker

Post by grimblefritz » 2016-04-06 15:35

For some reason my datepicker has weeks beginning on Monday (MTWTFSS)

How do I get it to display beginning on Sunday (SMTWTFS)?

jcrespi
Posts: 7
Joined: 2014-11-13 02:45

Re: Week begins on... in datepicker

Post by jcrespi » 2016-04-08 00:54

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.

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Week begins on... in datepicker

Post by grimblefritz » 2016-04-08 01:06

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.

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Week begins on... in datepicker

Post by peebee » 2016-04-08 03:28

From the plugin documentation here: http://freqdec.github.io/datePicker
The “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).
Edit the appropriate xx.js language file in /resources/datepicker/js/lang to suit your requirements

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Week begins on... in datepicker

Post by grimblefritz » 2016-04-08 11:26

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.

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: Week begins on... in datepicker

Post by peebee » 2016-04-08 23:05

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:

Code: Select all

        firstDayOfWeek:6,
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:

Code: Select all

<script type="text/javascript" src="./resources/datepicker/js/lang/en.js"></script>
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.

grimblefritz
AppGini Super Hero
AppGini Super Hero
Posts: 336
Joined: 2015-12-23 16:52

Re: Week begins on... in datepicker

Post by grimblefritz » 2016-04-09 01:35

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!

Post Reply