Lines Matching refs:tz

58 static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)  in read_preamble()  argument
67 tz->bc = (**tzf == '\1'); in read_preamble()
71 memcpy(tz->location.country_code, *tzf, 2); in read_preamble()
72 tz->location.country_code[2] = '\0'; in read_preamble()
81 static void read_header(const unsigned char **tzf, timelib_tzinfo *tz) in read_header() argument
86 tz->bit32.ttisgmtcnt = timelib_conv_int(buffer[0]); in read_header()
87 tz->bit32.ttisstdcnt = timelib_conv_int(buffer[1]); in read_header()
88 tz->bit32.leapcnt = timelib_conv_int(buffer[2]); in read_header()
89 tz->bit32.timecnt = timelib_conv_int(buffer[3]); in read_header()
90 tz->bit32.typecnt = timelib_conv_int(buffer[4]); in read_header()
91 tz->bit32.charcnt = timelib_conv_int(buffer[5]); in read_header()
95 static void skip_64bit_transistions(const unsigned char **tzf, timelib_tzinfo *tz) in skip_64bit_transistions() argument
97 if (tz->bit64.timecnt) { in skip_64bit_transistions()
98 *tzf += (sizeof(int64_t) * tz->bit64.timecnt); in skip_64bit_transistions()
99 *tzf += (sizeof(unsigned char) * tz->bit64.timecnt); in skip_64bit_transistions()
103 static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz) in read_transistions() argument
109 if (tz->bit32.timecnt) { in read_transistions()
110 buffer = (int32_t*) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t)); in read_transistions()
114 memcpy(buffer, *tzf, sizeof(int32_t) * tz->bit32.timecnt); in read_transistions()
115 *tzf += (sizeof(int32_t) * tz->bit32.timecnt); in read_transistions()
116 for (i = 0; i < tz->bit32.timecnt; i++) { in read_transistions()
120 cbuffer = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char)); in read_transistions()
125 memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit32.timecnt); in read_transistions()
126 *tzf += sizeof(unsigned char) * tz->bit32.timecnt; in read_transistions()
129 tz->trans = buffer; in read_transistions()
130 tz->trans_idx = cbuffer; in read_transistions()
133 static void skip_64bit_types(const unsigned char **tzf, timelib_tzinfo *tz) in skip_64bit_types() argument
135 *tzf += sizeof(unsigned char) * 6 * tz->bit64.typecnt; in skip_64bit_types()
136 *tzf += sizeof(char) * tz->bit64.charcnt; in skip_64bit_types()
137 if (tz->bit64.leapcnt) { in skip_64bit_types()
138 *tzf += sizeof(int64_t) * tz->bit64.leapcnt * 2; in skip_64bit_types()
140 if (tz->bit64.ttisstdcnt) { in skip_64bit_types()
141 *tzf += sizeof(unsigned char) * tz->bit64.ttisstdcnt; in skip_64bit_types()
143 if (tz->bit64.ttisgmtcnt) { in skip_64bit_types()
144 *tzf += sizeof(unsigned char) * tz->bit64.ttisgmtcnt; in skip_64bit_types()
148 static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) in read_types() argument
154 buffer = (unsigned char*) timelib_malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6); in read_types()
158 memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt); in read_types()
159 *tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt; in read_types()
161 tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo)); in read_types()
162 if (!tz->type) { in read_types()
167 for (i = 0; i < tz->bit32.typecnt; i++) { in read_types()
169tz->type[i].offset = (buffer[j] * 16777216) + (buffer[j + 1] * 65536) + (buffer[j + 2] * 256) + bu… in read_types()
170 tz->type[i].isdst = buffer[j + 4]; in read_types()
171 tz->type[i].abbr_idx = buffer[j + 5]; in read_types()
175 tz->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt); in read_types()
176 if (!tz->timezone_abbr) { in read_types()
179 memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->bit32.charcnt); in read_types()
180 *tzf += sizeof(char) * tz->bit32.charcnt; in read_types()
182 if (tz->bit32.leapcnt) { in read_types()
183 leap_buffer = (int32_t *) timelib_malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t)); in read_types()
187 memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->bit32.leapcnt * 2); in read_types()
188 *tzf += sizeof(int32_t) * tz->bit32.leapcnt * 2; in read_types()
190 tz->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo)); in read_types()
191 if (!tz->leap_times) { in read_types()
195 for (i = 0; i < tz->bit32.leapcnt; i++) { in read_types()
196 tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]); in read_types()
197 tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]); in read_types()
202 if (tz->bit32.ttisstdcnt) { in read_types()
203 buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char)); in read_types()
207 memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisstdcnt); in read_types()
208 *tzf += sizeof(unsigned char) * tz->bit32.ttisstdcnt; in read_types()
210 for (i = 0; i < tz->bit32.ttisstdcnt; i++) { in read_types()
211 tz->type[i].isstdcnt = buffer[i]; in read_types()
216 if (tz->bit32.ttisgmtcnt) { in read_types()
217 buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char)); in read_types()
221 memcpy(buffer, *tzf, sizeof(unsigned char) * tz->bit32.ttisgmtcnt); in read_types()
222 *tzf += sizeof(unsigned char) * tz->bit32.ttisgmtcnt; in read_types()
224 for (i = 0; i < tz->bit32.ttisgmtcnt; i++) { in read_types()
225 tz->type[i].isgmtcnt = buffer[i]; in read_types()
231 static void skip_posix_string(const unsigned char **tzf, timelib_tzinfo *tz) in skip_posix_string() argument
243 static void read_location(const unsigned char **tzf, timelib_tzinfo *tz) in read_location() argument
249 tz->location.latitude = timelib_conv_int(buffer[0]); in read_location()
250 tz->location.latitude = (tz->location.latitude / 100000) - 90; in read_location()
251 tz->location.longitude = timelib_conv_int(buffer[1]); in read_location()
252 tz->location.longitude = (tz->location.longitude / 100000) - 180; in read_location()
256 tz->location.comments = timelib_malloc(comments_len + 1); in read_location()
257 memcpy(tz->location.comments, *tzf, comments_len); in read_location()
258 tz->location.comments[comments_len] = '\0'; in read_location()
262 void timelib_dump_tzinfo(timelib_tzinfo *tz) in timelib_dump_tzinfo() argument
266 printf("Country Code: %s\n", tz->location.country_code); in timelib_dump_tzinfo()
267 printf("Geo Location: %f,%f\n", tz->location.latitude, tz->location.longitude); in timelib_dump_tzinfo()
268 printf("Comments:\n%s\n", tz->location.comments); in timelib_dump_tzinfo()
269 printf("BC: %s\n", tz->bc ? "" : "yes"); in timelib_dump_tzinfo()
270 printf("UTC/Local count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.ttisgmtcnt); in timelib_dump_tzinfo()
271 printf("Std/Wall count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.ttisstdcnt); in timelib_dump_tzinfo()
272 printf("Leap.sec. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.leapcnt); in timelib_dump_tzinfo()
273 printf("Trans. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.timecnt); in timelib_dump_tzinfo()
274 printf("Local types count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.typecnt); in timelib_dump_tzinfo()
275 printf("Zone Abbr. count: " TIMELIB_ULONG_FMT "\n", (timelib_ulong) tz->bit32.charcnt); in timelib_dump_tzinfo()
279 (long int) tz->type[0].offset, in timelib_dump_tzinfo()
280 tz->type[0].isdst, in timelib_dump_tzinfo()
281 tz->type[0].abbr_idx, in timelib_dump_tzinfo()
282 &tz->timezone_abbr[tz->type[0].abbr_idx], in timelib_dump_tzinfo()
283 tz->type[0].isstdcnt, in timelib_dump_tzinfo()
284 tz->type[0].isgmtcnt in timelib_dump_tzinfo()
286 for (i = 0; i < tz->bit32.timecnt; i++) { in timelib_dump_tzinfo()
288 tz->trans[i], tz->trans[i], tz->trans_idx[i], in timelib_dump_tzinfo()
289 (long int) tz->type[tz->trans_idx[i]].offset, in timelib_dump_tzinfo()
290 tz->type[tz->trans_idx[i]].isdst, in timelib_dump_tzinfo()
291 tz->type[tz->trans_idx[i]].abbr_idx, in timelib_dump_tzinfo()
292 &tz->timezone_abbr[tz->type[tz->trans_idx[i]].abbr_idx], in timelib_dump_tzinfo()
293 tz->type[tz->trans_idx[i]].isstdcnt, in timelib_dump_tzinfo()
294 tz->type[tz->trans_idx[i]].isgmtcnt in timelib_dump_tzinfo()
297 for (i = 0; i < tz->bit32.leapcnt; i++) { in timelib_dump_tzinfo()
299 tz->leap_times[i].trans, in timelib_dump_tzinfo()
300 (long) tz->leap_times[i].trans, in timelib_dump_tzinfo()
301 tz->leap_times[i].offset); in timelib_dump_tzinfo()
361 static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz) in skip_64bit_preamble() argument
366 static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz) in read_64bit_header() argument
371 tz->bit64.ttisgmtcnt = timelib_conv_int(buffer[0]); in read_64bit_header()
372 tz->bit64.ttisstdcnt = timelib_conv_int(buffer[1]); in read_64bit_header()
373 tz->bit64.leapcnt = timelib_conv_int(buffer[2]); in read_64bit_header()
374 tz->bit64.timecnt = timelib_conv_int(buffer[3]); in read_64bit_header()
375 tz->bit64.typecnt = timelib_conv_int(buffer[4]); in read_64bit_header()
376 tz->bit64.charcnt = timelib_conv_int(buffer[5]); in read_64bit_header()
408 static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts, timelib_sll *transition_ti… in fetch_timezone_offset() argument
414 if (!tz->bit32.timecnt || !tz->trans) { in fetch_timezone_offset()
416 if (tz->bit32.typecnt == 1) { in fetch_timezone_offset()
417 return &(tz->type[0]); in fetch_timezone_offset()
426 if (ts < tz->trans[0]) { in fetch_timezone_offset()
431 while (j < tz->bit32.timecnt && tz->type[tz->trans_idx[j]].isdst) { in fetch_timezone_offset()
434 if (j == tz->bit32.timecnt) { in fetch_timezone_offset()
437 return &(tz->type[tz->trans_idx[j]]); in fetch_timezone_offset()
442 for (i = 0; i < tz->bit32.timecnt; i++) { in fetch_timezone_offset()
443 if (ts < tz->trans[i]) { in fetch_timezone_offset()
444 *transition_time = tz->trans[i - 1]; in fetch_timezone_offset()
445 return &(tz->type[tz->trans_idx[i - 1]]); in fetch_timezone_offset()
448 *transition_time = tz->trans[tz->bit32.timecnt - 1]; in fetch_timezone_offset()
449 return &(tz->type[tz->trans_idx[tz->bit32.timecnt - 1]]); in fetch_timezone_offset()
452 static tlinfo* fetch_leaptime_offset(timelib_tzinfo *tz, timelib_sll ts) in fetch_leaptime_offset() argument
456 if (!tz->bit32.leapcnt || !tz->leap_times) { in fetch_leaptime_offset()
460 for (i = tz->bit32.leapcnt - 1; i > 0; i--) { in fetch_leaptime_offset()
461 if (ts > tz->leap_times[i].trans) { in fetch_leaptime_offset()
462 return &(tz->leap_times[i]); in fetch_leaptime_offset()
468 int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz) in timelib_timestamp_is_in_dst() argument
473 if ((to = fetch_timezone_offset(tz, ts, &dummy))) { in timelib_timestamp_is_in_dst()
479 timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz) in timelib_get_time_zone_info() argument
488 if ((to = fetch_timezone_offset(tz, ts, &transistion_time))) { in timelib_get_time_zone_info()
490 abbr = &(tz->timezone_abbr[to->abbr_idx]); in timelib_get_time_zone_info()
495 abbr = tz->timezone_abbr; in timelib_get_time_zone_info()
500 if ((tl = fetch_leaptime_offset(tz, ts))) { in timelib_get_time_zone_info()