-
Notifications
You must be signed in to change notification settings - Fork 1k
Change order of dateFormat and timeFormat #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes you can. |
Currently, the date string always in the format [date] + [separator] + [time]. In my case, I want it in [time] + [separator] + [date]. As of your recommendation, I think the output format will be: "2011/13/06 09:40". But it cannot be configured to be "09:40 2011/13/06", right? |
dinhtrung, You are correct, currently this is not possible, I guess if this is the case that would be useful as a regional setting. I think if you need to make this happen outputting the time would be (in the dev branch) line 707. Input/reading the datetime occurs on line 208-215. I think you just need to re-order the regex to look for date last. |
Yep, I add a new regional setting named 'dateBefore', and modify around line 707. It works. diff -r c90ab7be39d3 protected/extensions/widgets/datetimepicker/assets/jquery-ui-timepicker-addon.js
--- a/protected/extensions/widgets/datetimepicker/assets/jquery-ui-timepicker-addon.js Tue Jun 14 12:59:22 2011 +0700
+++ b/protected/extensions/widgets/datetimepicker/assets/jquery-ui-timepicker-addon.js Tue Jun 14 13:06:38 2011 +0700
@@ -38,6 +38,7 @@
hourText: 'Hour',
minuteText: 'Minute',
secondText: 'Second',
+ dateBefore: true,
timezoneText: 'Time Zone'
};
this._defaults = { // Global defaults for all the datetime picker instances
@@ -699,7 +700,11 @@
if (this._defaults.timeOnly === true) {
formattedDateTime = this.formattedTime;
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
- formattedDateTime += this._defaults.separator + this.formattedTime;
+ if (this._defaults.dateBefore){
+ formattedDateTime += this._defaults.separator + this.formattedTime;
+ } else {
+ formattedDateTime = this.formattedTime + this._defaults.separator + formattedDateTime;
+ }
}
this.formattedDateTime = formattedDateTime; |
Regional settings for Vietnamese: /* Vietnamese translation for the jQuery Timepicker Addon */
/* Written by Nguyen Dinh Trung */
$.timepicker.regional['vi'] = {
timeOnlyTitle: 'Chọn giờ',
timeText: 'Thời gian',
hourText: 'Giờ',
minuteText: 'Phút',
secondText: 'Giây',
timezoneText: 'Múi giờ',
currentText: 'Giờ hiện thời',
closeText: 'Đóng'
timeFormat: 'h:m',
ampm: false,
dateBefore: false,
};
$.timepicker.setDefaults($.timepicker.regional['vi']); |
Thanks for posting your changes and new regional settings. It works ok without changing lines 208-215? Can you re-open the datetimepicker and it parse the time correctly? |
Currently it is not working. I tried to reverse the regexp string, but still it cannot parse the date time correctly. My JS skill is not good enough to fix this bug. |
Sorry to jump in, but I believe Vietnamese's day time display (15/06/2011 13:37) is much similar to French's (http://en.wikipedia.org/wiki/Alexander_de_Rhodes, our Vietnamese scholars created the new Vietnamese writing system on top of the dictionary mentioned in the article) Here is minor revision: The translation will look to me like this: Can you kindly review and with Trent's help we can have the file committed to share? Of course additional modification can be made if better translation? Thanks, |
As to review the order between date and time, I navigate through some website in Vietnamese (yep, just to make sure). :D It is quite common to write in the format hh:ii dd/mm/YY. E.g: 14:17 | 14/06/2011 See: [http://baodientu.chinhphu.vn/] In some newspaper, I see the time put after date, but the date has weekday before. E.g: Thứ 4, 15/6/2011 - 01:32:36 PM. See: [http://vnexpress.net] I also prefer to put the time before the date part. |
Got you. Those are to say, either format is correct, and it does not request to one unified format only. -Châu |
I can go ahead and commit the translation, however after further thinking the beforeDate functionality will take a bit of time. I think changing timepicker will be fairly easy, but it will need to override datepicker, which may get tricky. datepicker expects the date to be first. Which format is the "formal" format? |
Well, the translation from cmhuynh is correct. About the beforeDate function, if it is digging too much into datepicker code, then currently i have no choice but to use the date first, then parse it from server, or the user will have to re-organize the date and sliders if the form already populate with defined values. I don't know if any other language in my case. If only Vietnamese, then we can close this issue. |
Ok, I will leave it open for a bit to see if anyone else can chime in on other languages needing this. I will go ahead and add that translation. Thank you for your input! |
Hi, Vietnamese is the only locale which the time part is put before the date part, as far as I know. Babel which Trac uses is a Python interface to CLDR (Common Locale Data Repository) and provides localized date time formatting. The following code is getting date time format from babel.
|
you'd better add some of those date format wiki to the release page, it's really helpful. |
there is a missing comma. @@ -10,7 +10,7 @@
millisecText: 'Phần nghìn giây',
timezoneText: 'Múi giờ',
currentText: 'Hiện thời',
- closeText: 'Đóng'
+ closeText: 'Đóng',
timeFormat: 'h:m',
amNames: ['SA', 'AM', 'A'],
pmNames: ['CH', 'PM', 'P'], |
hi...i am also using the jquery-ui.timepicker.addon.js....i just want to modify the format of the date...i want it yy-mm-dd instead of the timepicker format which is dd-mm-yy..i also want to change the separator / to - in the date...is this possible? where in the code i have to make adjustment to make this work? pls help..thanks |
That is a datepicker setting, read up on the dateFormat: |
Hello trent richardson..I really need your help Your date time picker addon is excellent however it shows as MM/DD/YY but i would like to change it to DD/MM/YY please- can you help me at all ? or anyone? |
I'm pretty late to the game, but I could use this functionality for a project I'm working on. Was a version of dinhtrung's change ever implemented? If so, what is the parameter name? Thanks |
My country (Vietnam) use the format "hh:ii:ss dd/mm/YY" to format the date and time.
Is there any way to change the order between dateFormat and timeFormat?
The text was updated successfully, but these errors were encountered: