libidav/utils.c

changeset 184
7ba3c97b31ff
parent 181
a8f8cdbf85df
child 185
cd42cccee550
equal deleted inserted replaced
183:c238e0017257 184:7ba3c97b31ff
134 if(tzinfo.length == 0) { 134 if(tzinfo.length == 0) {
135 // local time 135 // local time
136 tparts.tm_isdst = -1; 136 tparts.tm_isdst = -1;
137 return mktime(&tparts); 137 return mktime(&tparts);
138 } else if(!sstrcmp(tzinfo, S("Z"))) { 138 } else if(!sstrcmp(tzinfo, S("Z"))) {
139 #ifdef __FreeBSD__
140 return timegm(&tparts);
141 #else
139 return mktime(&tparts) - timezone; 142 return mktime(&tparts) - timezone;
143 #endif
140 } else if(tzinfo.ptr[0] == '+' || tzinfo.ptr[0] == '-') { 144 } else if(tzinfo.ptr[0] == '+' || tzinfo.ptr[0] == '-') {
141 int sign = (tzinfo.ptr[0] == '+') ? -1 : 1; 145 int sign = (tzinfo.ptr[0] == '+') ? -1 : 1;
142 146
143 if(tzinfo.length > 6) { 147 if(tzinfo.length > 6) {
144 return 0; 148 return 0;
145 } else { 149 } else {
146 tzinfo.ptr++; tzinfo.length--; 150 tzinfo.ptr++; tzinfo.length--;
147 extractval(tzinfo, conv, ':'); 151 extractval(tzinfo, conv, ':');
148 val = atol(conv); 152 val = atol(conv);
149 val = 60 * (val / 100) + (val % 100); 153 val = 60 * (val / 100) + (val % 100);
150 154 #ifdef __FreeBSD__
151 return mktime(&tparts) - timezone + (time_t) (60 * val * sign); 155 return timegm(&tparts) + (time_t) (60 * val * sign);
156 #else
157 return mktime(&tparts) - timezone + (time_t) (60 * val * sign);
158 #endif
152 } 159 }
153 } else { 160 } else {
154 return 0; 161 return 0;
155 } 162 }
156 } 163 }

mercurial