Implement %z for strptime.

PR:		kern/63064
Submitted by:	Stefan `Sec` Zehl <sec 42 org> (with some small changes)
MFC after:	1 month
This commit is contained in:
Xin LI 2009-06-25 23:59:23 +00:00
parent 256d01ee17
commit 40523da708

View File

@ -514,6 +514,34 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp)
}
}
break;
case 'z':
{
int sign = 1;
if (*buf != '+') {
if (*buf == '-')
sign = -1;
else
return 0;
}
buf++;
i = 0;
for (len = 4; len > 0; len--) {
if (isdigit((int)*buf)) {
i *= 10;
i += *buf - '0';
buf++;
} else
return 0;
}
tm->tm_hour -= sign * (i / 100);
tm->tm_min -= sign * (i % 100);
*GMTp = 1;
}
break;
}
}
return (char *)buf;