Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » EditField and DateFormat problems
icon14.gif  EditField and DateFormat problems [message #4480] Fri, 11 August 2006 21:02 Go to next message
exolon is currently offline  exolon
Messages: 62
Registered: July 2006
Location: 53'21N 6'18W
Member
This is great - I've been waiting for additions to the tutorial for a while, since I'm a total newbie.

However I noticed that the EditDate widget only seems to accept American (ie: annoying half-backwards, half-forwards) mm-dd-yyyy date formats, and it doesn't seem to have any methods to configure this behaviour (nor the fact that it seems to prompt on "invalid" dates such as 30/6/2006 which is the correct format here, when I try to close the app).
So.. I guess that's a bit strange and I can't see myself using such a widget, but it's great to see the tutorial being updated anyway with useful basic techniques.
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 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

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 #4483 is a reply to message #4480] Fri, 11 August 2006 21:38 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
exolon wrote on Fri, 11 August 2006 20:02


...since I'm a total newbie...
...
So.. I guess that's a bit strange and I can't see myself using such a widget,...


So, don't spend time guessing imaginable problems... See a problem - ask questions. Don't be shy! Smile
Re: EditField topic created, chapters 17 and 18 of GUI tutorial added [message #4484 is a reply to message #4480] Fri, 11 August 2006 21:39 Go to previous messageGo to next message
exolon is currently offline  exolon
Messages: 62
Registered: July 2006
Location: 53'21N 6'18W
Member
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 Smile
Re: EditField topic created, chapters 17 and 18 of GUI tutorial added [message #4485 is a reply to message #4484] Fri, 11 August 2006 21:43 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

Actually, it looks like those settings are only there for like 6 "major" languages.
An easier way:
SetDateScan("dmy");
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 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior 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 Smile


But...please, "open your mouth" in the appropriate sections (for the sake of others)...(This is a releases log...) Happy openings!... Smile

[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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
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:
SetDateScan("dmy");



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 Go to previous messageGo to next message
exolon is currently offline  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:
SetDateScan("dmy");



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? Smile

[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 Smile

[/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 Go to previous messageGo to next message
rbmatt is currently offline  rbmatt
Messages: 90
Registered: July 2006
Location: Tennesse, USA
Member

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

icon7.gif  Re: EditField and DateFormat problems [message #4493 is a reply to message #4480] Sat, 12 August 2006 02:09 Go to previous messageGo to next message
exolon is currently offline  exolon
Messages: 62
Registered: July 2006
Location: 53'21N 6'18W
Member
Spot on - adding the missing SetDateFormat fixed it.

Changing the code to:
GUI_APP_MAIN
{
	SetLanguage(LNGC_('E', 'N', 'I', 'E', CHARSET_UTF8));
	SetDateScan("dmy");
	SetDateFormat("%3:02d/%2:02d/%1:4d");
	MainGui().Run();
}

Works perfectly. I'm a happy camper. Thanks Rbmatt and Luzr (and Fudadmin for moving this to a more useful place).

btw: I mentioned about the slowness of gcc's linker, but after switching to build with MSC8, the difference is striking - MSC8 seems to link about 10 times faster than gcc's ld! What the hell are they doing to take so much time...
Re: EditField and DateFormat problems [message #4496 is a reply to message #4493] Sat, 12 August 2006 09:13 Go to previous message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
exolon wrote on Fri, 11 August 2006 20:09

Spot on - btw: I mentioned about the slowness of gcc's linker, but after switching to build with MSC8, the difference is striking - MSC8 seems to link about 10 times faster than gcc's ld! What the hell are they doing to take so much time...


Actually, the fastest combo around is still MSC7.1 - compiler is faster than 8.0 and good enough to compile all template stuff in U++ without problem.

I believe that MSC7.1 with U++/BLITZ is the fastest C++ compilation in the universe Smile (Of course, as long as universe is limited in time and space so that parallel evolution somewhere else did not resulted in exact same C++ specification and better compiler writers Smile

Mirek
Previous Topic: incorrect date format for hungarian language
Next Topic: TheIDE fie choser dialog can't recongize Chinese
Goto Forum:
  


Current Time: Thu Nov 14 19:56:35 CET 2019

Total time taken to generate the page: 0.03092 seconds