Mercurial > hg > nginx
annotate src/http/ngx_http_parse_time.c @ 122:cd91e4a1ad0d
nginx-0.0.1-2003-07-23-17:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 23 Jul 2003 13:10:12 +0000 |
parents | a499e0d1f16e |
children | 9f3a78b06c48 |
rev | line source |
---|---|
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
2 #include <ngx_config.h> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
3 #include <ngx_core.h> |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
4 #include <ngx_types.h> |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
5 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
6 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
7 static int mday[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
9 time_t ngx_http_parse_time(char *value, size_t len) |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
10 { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
11 char *p, *end; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
12 int day, month, year, hour, min, sec; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
13 enum { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
14 no = 0, |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
15 rfc822, /* Tue 10 Nov 2002 23:50:13 */ |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
16 rfc850, /* Tuesday, 10-Dec-02 23:50:13 */ |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
17 isoc /* Tue Dec 10 23:50:13 2002 */ |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
18 } fmt; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
19 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
20 fmt = 0; |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
21 end = value + len; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 |
57
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
23 #if (NGX_SUPPRESS_WARN) |
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
24 day = 32; |
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
25 year = 2038; |
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
26 #endif |
a499e0d1f16e
nginx-0.0.1-2003-01-30-10:28:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
44
diff
changeset
|
27 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
28 for (p = value; p < end; p++) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
29 if (*p == ',') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
30 break; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
31 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
33 if (*p == ' ') { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
34 fmt = isoc; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
35 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
36 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
37 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
39 for (p++; p < end; p++) |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
40 if (*p != ' ') { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 break; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
42 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
44 if (end - p < 18) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
45 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
46 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
47 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
48 if (fmt != isoc) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
49 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
50 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
51 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
52 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
53 day = (*p - '0') * 10 + *(p + 1) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
54 p += 2; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
55 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
56 if (*p == ' ') { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
57 if (end - p < 18) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
58 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
59 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
60 fmt = rfc822; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
61 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
62 } else if (*p == '-') { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
63 fmt = rfc850; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
64 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
65 } else { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
66 return NGX_ERROR; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
67 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
68 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
69 p++; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
70 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
71 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
72 switch (*p) { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
73 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
74 case 'J': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
75 month = *(p + 1) == 'a' ? 0 : *(p + 2) == 'n' ? 5 : 6; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
76 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
77 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
78 case 'F': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
79 month = 1; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
80 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
81 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
82 case 'M': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
83 month = *(p + 2) == 'r' ? 2 : 4; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
84 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
85 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
86 case 'A': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
87 month = *(p + 1) == 'p' ? 3 : 7; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
88 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
89 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
90 case 'S': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
91 month = 8; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
92 break; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
93 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
94 case 'O': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
95 month = 9; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
96 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
97 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
98 case 'N': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
99 month = 10; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
100 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
101 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
102 case 'D': |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
103 month = 11; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
104 break; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
105 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
106 default: |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
107 return NGX_ERROR; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
108 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
109 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
110 p += 3; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
111 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
112 if ((fmt == rfc822 && *p != ' ') || (fmt == rfc850 && *p != '-')) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
113 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
114 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
115 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
116 p++; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
117 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
118 if (fmt == rfc822) { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
119 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9' |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
120 || *(p + 2) < '0' || *(p + 2) > '9' |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
121 || *(p + 3) < '0' || *(p + 3) > '9') |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
122 { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
123 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
124 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
125 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
126 year = (*p - '0') * 1000 + (*(p + 1) - '0') * 100 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
127 + (*(p + 2) - '0') * 10 + *(p + 3) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
128 p += 4; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
129 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
130 } else if (fmt == rfc850) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
131 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
132 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
133 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
134 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
135 year = (*p - '0') * 10 + *(p + 1) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
136 year += (year < 70) ? 2000 : 1900; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
137 p += 2; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
138 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
139 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
140 if (fmt == isoc) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
141 if (*p == ' ') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
142 p++; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
143 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
144 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
145 if (*p < '0' || *p > '9') { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
147 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
149 day = *p++ - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
150 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
151 if (*p != ' ') { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
152 if (*p < '0' || *p > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
153 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
154 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
155 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
156 day = day * 10 + *p++ - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
157 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
158 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
159 if (end - p < 14) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
160 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
161 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
162 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
163 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
164 if (*p++ != ' ') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
165 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
166 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
167 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
168 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
169 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
170 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
171 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
172 hour = (*p - '0') * 10 + *(p + 1) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
173 p += 2; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
175 if (*p++ != ':') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
176 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
177 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
178 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
179 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
180 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
181 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
182 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
183 min = (*p - '0') * 10 + *(p + 1) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
184 p += 2; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
185 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
186 if (*p++ != ':') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
187 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
188 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
190 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
191 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
192 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
193 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
194 sec = (*p - '0') * 10 + *(p + 1) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
195 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
196 if (fmt == isoc) { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
197 p += 2; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
198 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
199 if (*p++ != ' ') { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
200 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
201 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
202 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
203 if (*p < '0' || *p > '9' || *(p + 1) < '0' || *(p + 1) > '9' |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
204 || *(p + 2) < '0' || *(p + 2) > '9' |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
205 || *(p + 3) < '0' || *(p + 3) > '9') |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
206 { |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
208 } |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
210 year = (*p - '0') * 1000 + (*(p + 1) - '0') * 100 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
211 + (*(p + 2) - '0') * 10 + *(p + 3) - '0'; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
212 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
213 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
214 #if 0 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
215 printf("%d.%d.%d %d:%d:%d\n", day, month + 1, year, hour, min, sec); |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
216 #endif |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
217 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
218 if (hour > 23 || min > 59 || sec > 59) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
219 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
220 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
221 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
222 if (day == 29 && month == 1) { |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
223 if ((year & 3) || ((year % 100 == 0) && (year % 400) != 0)) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
224 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
225 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
226 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
227 } else if (day > mday[month]) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
228 return NGX_ERROR; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
229 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
230 |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
231 if (sizeof(time_t) <= 4 && year >= 2038) { |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
232 return NGX_ERROR; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
29
diff
changeset
|
233 } |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
234 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
235 /* shift new year to 1st March, needed for Gauss's formula */ |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
236 if (--month <= 0) { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
237 month += 12; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
238 year -= 1; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
239 } |
29
6a0b3d6e9c13
nginx-0.0.1-2002-12-17-18:48:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
240 /* Gauss's formula for Grigorian days from 1 March 1 BC */ |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
241 return (365 * year + year / 4 - year / 100 + year / 400 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
242 + 367 * month / 12 + day - 31 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
243 /* 719527 days are between 1 March 1 BC and 1 March 1970, |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
244 31 and 28 days in Jan and Feb 1970 */ |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
245 - 719527 + 31 + 28) * 86400 + hour * 3600 + min * 60 + sec; |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
246 } |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
247 |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
248 #if 0 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
249 char zero[] = "Sun, 01 Jan 1970 08:49:30"; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
250 char one[] = "Sunday, 11-Dec-02 08:49:30"; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
251 char two[] = "Sun Mar 1 08:49:37 2000"; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
252 char thr[] = "Sun Dec 11 08:49:37 2002"; |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
253 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
254 main() |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
255 { |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
256 int rc; |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
258 rc = ngx_http_parse_time(zero, sizeof(zero) - 1); |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
259 printf("rc: %d\n", rc); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
261 rc = ngx_http_parse_time(one, sizeof(one) - 1); |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
262 printf("rc: %d\n", rc); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 |
25
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
264 rc = ngx_http_parse_time(two, sizeof(two) - 1); |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
265 printf("rc: %d\n", rc); |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
266 |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
267 rc = ngx_http_parse_time(thr, sizeof(thr) - 1); |
a8b156554dfe
nginx-0.0.1-2002-12-11-19:57:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
268 printf("rc: %d\n", rc); |
24
77c7629a2627
nginx-0.0.1-2002-12-10-21:05:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
269 } |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
270 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
25
diff
changeset
|
271 #endif |