MCPcopy Create free account
hub / github.com/eggert/tz / getleapdatetime

Function getleapdatetime

zic.c:2297–2360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2295 warning(N_("format '%s' not handled by pre-2015 versions of zic"),
2296 fields[i_format]);
2297 }
2298 zones = growalloc(zones, sizeof *zones, nzones, &nzones_alloc);
2299 zones[nzones++] = z;
2300 /*
2301 ** If there was an UNTIL field on this line,
2302 ** there's more information about the zone on the next line.
2303 */
2304 return hasuntil;
2305}
2306
2307static zic_t
2308getleapdatetime(char **fields, bool expire_line)
2309{
2310 register const char * cp;
2311 register const struct lookup * lp;
2312 register zic_t i, j;
2313 zic_t year;
2314 int month, day;
2315 zic_t dayoff, tod;
2316 zic_t t;
2317 char xs;
2318
2319 dayoff = 0;
2320 cp = fields[LP_YEAR];
2321 if (sscanf(cp, "%"SCNdZIC"%c", &year, &xs) != 1) {
2322 /*
2323 ** Leapin' Lizards!
2324 */
2325 error(N_("invalid leaping year"));
2326 return -1;
2327 }
2328 if (!expire_line) {
2329 if (!leapseen || leapmaxyear < year)
2330 leapmaxyear = year;
2331 if (!leapseen || leapminyear > year)
2332 leapminyear = year;
2333 leapseen = true;
2334 }
2335 j = EPOCH_YEAR;
2336 while (j != year) {
2337 if (year > j) {
2338 i = len_years[isleap(j)];
2339 ++j;
2340 } else {
2341 --j;
2342 i = -len_years[isleap(j)];
2343 }
2344 dayoff = oadd(dayoff, i);
2345 }
2346 if ((lp = byword(fields[LP_MONTH], mon_names)) == NULL) {
2347 error(N_("invalid month name"));
2348 return -1;
2349 }
2350 month = lp->l_value;
2351 j = TM_JANUARY;
2352 while (j != month) {
2353 i = len_months[isleap(year)][j];
2354 dayoff = oadd(dayoff, i);

Callers 2

inleapFunction · 0.85
inexpiresFunction · 0.85

Calls 6

errorFunction · 0.85
oaddFunction · 0.85
bywordFunction · 0.85
omulFunction · 0.85
gethmsFunction · 0.85
taddFunction · 0.85

Tested by

no test coverage detected