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 » LineEdit, EditFields, DocEdit » EditTime - how to change format?- [SOLVED]-EditField & Convert
Re: EditTime - Is it possible to change displayed format? [message #570 is a reply to message #567] Mon, 09 January 2006 23:26 Go to previous messageGo to previous message
Garry is currently offline  Garry
Messages: 7
Registered: November 2005
Promising Member
Thanks a million - it took me a while to figure out how to do it properly, but I've got it now. Certainly a great learning experience too. Now I realise how to make much better use out of Browser++ too!!

Anyway, here's my code now:
class MyTimeConvert: public ConvertTime {

	public:
	Value Format(const Value& q) const {
		Time tm = q;
		return ::Format("%02d:%02d", tm.hour, tm.minute);      //ensures xx:xx format
	}
	int Filter(int chr) const {
	if(IsDigit(chr) || chr == ':')                        //only accepts digits and ":"
		return chr;
	return 0;
	}
};


typedef EditMinMax<Time, MyTimeConvert> EditTimeHM;


I only need Format to display hours and minutes with two digits for each unit.

This abridged version of Filter only allows digits and the colon symbol.

The standard version of Scan seems to work well at interpreting the time in this manner, but I might alter it in my own program so that invalid times are converted to proper times (eg 25:01 becomes 01:01).


By the way, now that I understand the actual processes behind this, I think there's a bug in ConvertTime. The global Format produces a String of Time with forward slashes "/" dividing days, months and years but ConvertTime::Scan and ConvertTime::Filter expect full stops instead ".". This causes EditTime to refuse to close once any time has been entered.

All the best, and thanks again!
Garry

*edit fixed a typo

[Updated on: Mon, 09 January 2006 23:27]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Trouble with EditTime
Next Topic: DocEdit code scrolling
Goto Forum:
  


Current Time: Sun Apr 28 13:21:07 CEST 2024

Total time taken to generate the page: 0.01853 seconds