-
Notifications
You must be signed in to change notification settings - Fork 3
/
caltime_scan.c
40 lines (33 loc) · 1.05 KB
/
caltime_scan.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "caltime.h"
unsigned int caltime_scan(s,ct)
char *s;
struct caltime *ct;
{
char *t = s;
unsigned long z;
unsigned long c;
int sign;
t += caldate_scan(t,&ct->date);
while ((*t == ' ') || (*t == '\t') || (*t == 'T')) ++t;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->hour = z;
if (*t++ != ':') return 0;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->minute = z;
if (*t != ':')
ct->second = 0;
else {
++t;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->second = z;
}
while ((*t == ' ') || (*t == '\t')) ++t;
if (*t == '+') sign = 1; else if (*t == '-') sign = -1; else return 0;
++t;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 10 + c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 6 + c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 10 + c;
ct->offset = z * sign;
return t - s;
}