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++ Library : Other (not classified elsewhere) » [FEATURE REQUEST] Time to UTC ISO 8601 and UTC ISO 8601 to Time
Re: [FEATURE REQUEST] Time to UTC ISO 8601 and UTC ISO 8601 to Time [message #18334 is a reply to message #14047] Tue, 23 September 2008 13:52 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3361
Registered: August 2008
Senior Veteran
Hello luzr

Please check if it could serve.

Best regards
Koldo

const char *StrToTime(Time& d, const char *s)
{
	s = StrToDate(d, s);
	
	d.hour = 0;
	d.minute = 0;
	d.second = 0;
	
	const char *fmt = "hms";
	 
	while(*fmt) {
		while(*s && !IsDigit(*s))
			s++;
		int n;
		if(IsDigit(*s)) {
			char *q;
			n = strtoul(s, &q, 10);
			s = q;
		} else
			break;

		switch(*fmt) {
		case 'h':
			if(n < 0 || n > 23)
				return NULL;
			d.hour = n;
			break;
		case 'm':
			if(n < 0 || n > 59)
				return NULL;
			d.minute = n;
			break;
		case 's':
			if(n < 0 || n > 59)
				return NULL;
			d.second = n;
			break;
		default:
			NEVER();
		}
		fmt++;
	}
	return d.IsValid() ? s : NULL;
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Small Correction about Vista/GLCtrl corrections
Next Topic: Missing methods in Win32 version of GLCtrl
Goto Forum:
  


Current Time: Wed May 15 19:26:09 CEST 2024

Total time taken to generate the page: 0.01393 seconds