[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-common-cvs
Subject: [Common-cvs] util timerep.cpp,1.18,1.18.2.1
From: xzhao () helixcommunity ! org
Date: 2012-08-10 3:23:10
[Download RAW message or body]
Update of /cvsroot/common/util
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv22750
Modified Files:
Tag: hxclient_3_1_0_atlas
timerep.cpp
Log Message:
Add one more time format for UTC time convert
Index: timerep.cpp
===================================================================
RCS file: /cvsroot/common/util/timerep.cpp,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- timerep.cpp 6 Jul 2007 20:39:16 -0000 1.18
+++ timerep.cpp 10 Aug 2012 03:21:38 -0000 1.18.2.1
@@ -601,16 +601,20 @@
* RFC1123: wkday "," SP DD SP month SP YYYY HH:MM:SS (Wed, 02 Jun 1982)
* RFC850 : weekday "," SP DD-month-YY HH:MM:SS (Wednesday, 02-Jun-82)
* asctime: wkday SP month SP dD HH:MM:SS YYYY (Wed Jun 2 09:00:00 1982)
- * UTC : YYYYMMDD'T'HHMMSS'Z'
+ * UTC : Type1 : YYYYMMDD'T'HHMMSS'Z' Type2 : YYYY-MM-DD'T'HH:MM:SS
*/
if (isdigit(pStr[0]))
{
// UTC
- if(strlen(pStr) != 16)
+ unsigned int len = strlen(pStr);
+ if(len != 16 && len != 19)
{
goto bail;
}
+ if (len == 16)
+ {
+ // YYYYMMDD'T'HHMMSS'Z'
for (n = 0; n < 8; n++)
{
if (!isdigit(pStr[n]))
@@ -633,6 +637,24 @@
stm.tm_hour = (pStr[9]-'0')*10 + (pStr[10]-'0');
stm.tm_min = (pStr[11]-'0')*10 + (pStr[12]-'0');
stm.tm_sec = (pStr[13]-'0')*10 + (pStr[14]-'0');
+ }
+ else if (len == 19)
+ {
+ // YYYY-MM-DD'T'HH:MM:SS
+ if (pStr[10] != 'T')
+ {
+ goto bail;
+ }
+ // The number of years since 1900
+ stm.tm_year = (pStr[0]-'0')*1000 + (pStr[1]-'0')*100 +
+ (pStr[2]-'0')*10 + (pStr[3]-'0') - 1900;
+ // The number of months since January, in the range 0 to 11
+ stm.tm_mon = (pStr[5]-'0')*10 + (pStr[6]-'0') - 1;
+ stm.tm_mday = (pStr[8]-'0')*10 + (pStr[9]-'0');
+ stm.tm_hour = (pStr[11]-'0')*10 + (pStr[12]-'0');
+ stm.tm_min = (pStr[14]-'0')*10 + (pStr[15]-'0');
+ stm.tm_sec = (pStr[17]-'0')*10 + (pStr[18]-'0');
+ }
// We have a struct tm in GMT
return fromUTCTm(&stm);
_______________________________________________
Common-cvs mailing list
Common-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/common-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic