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 |
|
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.
|
|
|
Goto Forum:
Current Time: Tue Jun 04 00:30:26 CEST 2024
Total time taken to generate the page: 0.02327 seconds
|