Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » EditField and DateFormat problems
|
Re: EditField topic created, chapters 17 and 18 of GUI tutorial added [message #4482 is a reply to message #4480] |
Fri, 11 August 2006 21:20 |
|
EditDate is dependant on language. For example if you set your app to russian:
SetLanguage(LNGC_('R', 'U', 'R', 'U', CHARSET_WIN1251));
then 30.1.2005 is a correct format.
--My guess is you want LNGC_('E','N','I','E', CHARSET_UTF8) but it doesnt look like that works as expected
[Updated on: Fri, 11 August 2006 21:32] Report message to a moderator
|
|
|
|
|
|
Re: EditField topic created, chapters 17 and 18 of GUI tutorial added [message #4486 is a reply to message #4484] |
Fri, 11 August 2006 21:46 |
|
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
exolon wrote on Fri, 11 August 2006 20:39 | Ah, that makes sense, thanks rbmatt. I'll experiment with locale language settings then.
About the control calling PromptOK when you try to close its parent window if the date entered doesn't validate, is this a setting you can disable, or am I just using it wrong?
I just added it to an existing layout with the (very nice) visual editor.
p.s. Fudadmin: don't worry, I'm not shy at all - I'm always happy to open my big mouth, even if I look like a fool afterwards
|
But...please, "open your mouth" in the appropriate sections (for the sake of others)...(This is a releases log...) Happy openings!...
[Updated on: Fri, 11 August 2006 21:50] Report message to a moderator
|
|
|
Re: EditField topic created, chapters 17 and 18 of GUI tutorial added [message #4487 is a reply to message #4485] |
Fri, 11 August 2006 23:29 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
rbmatt wrote on Fri, 11 August 2006 15:43 | Actually, it looks like those settings are only there for like 6 "major" languages.
An easier way:
|
Actually, there are two.
SetDateScan makes for ordering of "day" "month" "year" while parsing text to date (note that parsing is quite benevolent - even month names are tested, year can be YY or YYYY, separators is anything non al-num). There is also SetDateFilter that setups a filter function of date characters.
Opposite conversion is expressed by SetDateFormat - takes a Date, results text. It simply calls Format on the formatting string and date.year, date.month, date.day, DayOfWeek(date) as parameters. Formatting is flexible enough to convert these to any date needed.
When you do SetLanguage, all that really happens is this:
SetDateFormat(t_("date-format\a%2:02d/%3:02d/%1:4d"));
SetDateScan(t_("date-scan\amdy"));
SetDateFilter(t_("date-filter\aA/\a .-"));
Means those date formatting settings are assigned a "translation" of en-us formatting settings... (the moral of story is that if you want different settings, setup them after calling the SetLanguage).
Mirek
|
|
|
EditField and DateFormat problems [message #4490 is a reply to message #4487] |
Sat, 12 August 2006 00:52 |
exolon
Messages: 62 Registered: July 2006 Location: 53'21N 6'18W
|
Member |
|
|
luzr wrote on Fri, 11 August 2006 22:29 |
rbmatt wrote on Fri, 11 August 2006 15:43 | Actually, it looks like those settings are only there for like 6 "major" languages.
An easier way:
|
Actually, there are two.
SetDateScan makes for ordering of "day" "month" "year" while parsing text to date (note that parsing is quite benevolent - even month names are tested, year can be YY or YYYY, separators is anything non al-num). There is also SetDateFilter that setups a filter function of date characters.
|
That seems great... but I still can't make it work.
GUI_APP_MAIN
{
SetLanguage(LNGC_('E', 'N', 'I', 'E', CHARSET_UTF8));
SetDateScan("dmy");
//SetDateScan(t_("date-scan\admy")); // neither of these work
MainGui().Run();
}
Still defaults to American style dates (although I like the dynamic background-colour changing when it sees a date it thinks is invalid - 02/29/2001 stays light red, but 02/29/2000 goes white... although apparently century years don't count as leap years ;P).
What am I still doing wrong?
[edit]
BTW: Specifically, what's happening is that as I type a date (eg: 20/7/2006) into the EditDate gadget, it stays white, indicating a valid date... but as soon as I move focus away from the control by tabbing to another control or clicking away, the date immediately changes from "20/7/2006" to "07/20/2006" and the background colour changes to the "invalid date" colour. Then, I can't close the application without clearing the date field (or entering a neutral date such as 12/12/2006).
ps. Fudadmin, I agree that my offtopic problems with this widget would be better placed in say... the "problems with widgets" subforum or similar... bit late now though
[/edit...]
[Updated on: Sat, 12 August 2006 02:02] by Moderator Report message to a moderator
|
|
|
EditField and DateFormat problems [message #4491 is a reply to message #4490] |
Sat, 12 August 2006 01:51 |
|
exolon wrote on Fri, 11 August 2006 18:52 | BTW: Specifically, what's happening is that as I type a date (eg: 20/7/2006) into the EditDate gadget, it stays white, indicating a valid date... but as soon as I move focus away from the control by tabbing to another control or clicking away, the date immediately changes from "20/7/2006" to "07/20/2006" and the background colour changes to the "invalid date" colour. Then, I can't close the application without clearing the date field (or entering a neutral date such as 12/12/2006).
|
You need to SetDateFormat to your preferred settings also. Here's how I understand this to work:
When you enter a date, its a 100% raw string. Then it uses DateScan to parse it into Year, Month, and Day internal variables. Then at some later point in time, it is formatted according to DateFormat. DateFormat takes the internal variables and puts it back into a string. This helps to make all dates similar, 1/1/06 would turn into 01/01/2006. It's just good measure. Then its saved.
The problem is your DateFormat is not compatible to your DateScan.
[Updated on: Sat, 12 August 2006 02:02] by Moderator Report message to a moderator
|
|
|
|
|
Goto Forum:
Current Time: Sat May 04 09:14:04 CEST 2024
Total time taken to generate the page: 0.03148 seconds
|