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 » Community » U++ community news and announcements » Json Date/Time support
Re: Json Date/Time support [message #40907 is a reply to message #40904] Sun, 06 October 2013 19:55 Go to previous messageGo to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

That's great to have it, but I had it already implemented in my private branch. But my solution checked if the json value can be converted to a date using IsDateString function:
bool IsDateString(const String& s)
{
	if(s.GetLength() != 10)
		return false;
	
	int cnt = 0;
	for(int i = 0; i < s.GetLength(); i++) {
		if(IsAlpha(s[i]) || IsSpace(s[i]))
			return false;
		if(!IsDigit(s[i]))
			 ++cnt;
	}
	return cnt == 2;
}

and then in ParseJSON I changed if(p.IsString()) section to:
if(p.IsString())
{
	String s = p.ReadString();
	if(IsDateString(s)) {
		Date d = ScanDate(s);
		if(!IsNull(d))
			return d;
	}
	return s;
}

The good thing is it does accept most of the date formats that satisfy ScanDate function.
However relaying on unofficial standard might be better.
 
Read Message
Read Message
Read Message
Previous Topic: Ide improvements
Next Topic: ArrayCtrl: Set/Add maps
Goto Forum:
  


Current Time: Sat May 11 21:32:14 CEST 2024

Total time taken to generate the page: 0.01740 seconds