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