Date Picker

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Paul
Profound User
Posts: 39
Joined: Mon Aug 29, 2011 10:53 pm
First Name: Paul
Last Name: Foster
Company Name: GRI Group Ltd
Country: Hong Kong
Location: Hong Kong
Contact:

Date Picker

Post by Paul »

I have a date picker problem. If a date field is defined with a US locale then the first day of the week in the date picker is Sunday. However, if I use a locale of United Kingdom (to get DD/MM/YY format) then the first day in the date picker becomes Monday even though the startDay in ExtJS DatePicker is set to the default 0.

As our week is Sunday-Saturday I would prefer the start day to be Sunday, as it is in the US locale. Any suggestions?

Thanks,

Paul
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Date Picker

Post by Scott Klement »

This is controlled by a locale file. We have all of the locales for the differnt countries built-in to profound ui, but, you could create your own custom locale that overrides the settings.

To do that, create a file in /www/YOUR-INSTANCE/htdocs/profoundui/userdata/custom/js -- maybe call it something like custom_locale.js. Put the following in that file:

Code: Select all

pui.locales.add({
  name: "custom_locale",
  text: "English (United Kingdom)",
  datePatterns: [
    'Y-m-d',
    'd.m.y',
    'd.m.Y',
    'd/m/y',
    'd/m/Y',
    'd-m-y',
    'd-m-Y',
	  'Y/m',
	  'Y/m/d',
    'j F y',
    'j F Y',
    'l j F y',
	  'l j F Y',
    'D d M y',
    'D d M Y',
    'j-M-y',
    'j-M-Y',
    'j M y',
    'j M Y'
  ],
  timePatterns: [
    'g:i',
    'g:i:s',
	  'g:i a',
    'g:i A',
    'H:i',
    'H.i.s',
    'H:i:s',
	  'H:i a',
	  'H:i A',
    'g:i:s a',
    'g:i:s A',
    'H:i:s a',
    'H:i:s A'
  ],
  timeStampPatterns: [
    'D d M Y H:i:s',
    'd.m.y g:i A',
    'd.m.y g:i a',
    'd.m.y H:i:s',
    'd/m/y g:i A',
    'd/m/y g:i a',
    'd/m/y H:i:s',
    'd-m-y g:i A',
    'd-m-y g:i a',
    'd-m-y H:i:s',
    'g:i A o\\n n/j/y',
    'Y-m-d-H.i.s.uu'
  ],
  'monthNames': [
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December'
  ],
  'shortMonthNames': [
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec'
  ],
  'dayNames': [
    'Sunday',
    'Monday',
    'Tuesday',
    'Wednesday',
    'Thursday',
    'Friday',
    'Saturday'
  ],
  'shortDayNames': [
    'Sun',
    'Mon',
    'Tue',
    'Wed',
    'Thu',
    'Fri',
    'Sat'
  ],
  'weekStart': 0
});
The important bit is the name at the top ("custom_locale") this is the locale name that you need to use in order to pick up these settings. And the "weekStart" value at the bottom. The default weekStart for the UK is 1 -- but in this case, it's been changed to 0 (for Sunday).

Let me know if that helps
Paul
Profound User
Posts: 39
Joined: Mon Aug 29, 2011 10:53 pm
First Name: Paul
Last Name: Foster
Company Name: GRI Group Ltd
Country: Hong Kong
Location: Hong Kong
Contact:

Re: Date Picker

Post by Paul »

Almost, but not quite ....

The custom locale appears in the dropdown, but there are no Date Formats shown, only "default". The DatePatterns look fine in the js, but they aren't displaying

If I select the default and save/compile it picks up the custom js (I changed a couple of month names to verifiy this) and the start day is Sunday, but after selecting a date I just get "undefined" in the field.

Also, I can't change it back in Designer, it no longer loads the date options on a double-click, so I had to recreate the field.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Date Picker

Post by Scott Klement »

This appears to be a bug in Profound UI. I'll look into it and get back to you.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Date Picker

Post by Scott Klement »

I found the problem, and fixed the bug on our development box. The fix will be included in the next release of Profound UI. With this fix, you can successfully load a custom locale.

If you need a fix sooner, please e-mail support@profoundlogic.com, and request a patch to fix issue #225.

Thanks!
Paul
Profound User
Posts: 39
Joined: Mon Aug 29, 2011 10:53 pm
First Name: Paul
Last Name: Foster
Company Name: GRI Group Ltd
Country: Hong Kong
Location: Hong Kong
Contact:

Re: Date Picker

Post by Paul »

Many thanks Scott, I can wait for next scheduled release. Apologies for late reply, I've been away.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Date Picker

Post by Scott Klement »

Profound UI 4.5.0 has been released, and contains the fix for this issue. With this new release, you should be able to load a locale (as I described earlier, though in hindsight, I should've changed the "text" field to something like "UK Custom" so you could see which one is the custom locale.)

Anyway, the new release is out... should fix the problem loading the locale.
Paul
Profound User
Posts: 39
Joined: Mon Aug 29, 2011 10:53 pm
First Name: Paul
Last Name: Foster
Company Name: GRI Group Ltd
Country: Hong Kong
Location: Hong Kong
Contact:

Re: Date Picker

Post by Paul »

Thanks Scott, all works well. I spotted the duplicated text field and have unique one.

Now for the tricky part! Our months are structured using 4-5-4 accounting months. As our financial year begins in Feb, the first week of our year for 2013 is Sun Feb 3rd, and the last day of the financial month of Feb is Sat Mar 2nd. Is there any way that the calendar could be over-ridden to use these financial dates?

If its not possible then no worries, its just a nice-to-have.

Cheers,

Paul
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests