| 2390 | |
| 2391 | #if defined(ANDROID) || defined(__ANDROID__) |
| 2392 | void |
| 2393 | time_zone::parse_from_android_tzdata(std::ifstream& inf, const std::size_t off) |
| 2394 | { |
| 2395 | using namespace std; |
| 2396 | using namespace std::chrono; |
| 2397 | if (!inf.is_open()) |
| 2398 | throw std::runtime_error{"Unable to open tzdata"}; |
| 2399 | std::size_t restorepos = inf.tellg(); |
| 2400 | inf.seekg(off, inf.beg); |
| 2401 | load_header(inf); |
| 2402 | auto v = load_version(inf); |
| 2403 | std::int32_t tzh_ttisgmtcnt, tzh_ttisstdcnt, tzh_leapcnt, |
| 2404 | tzh_timecnt, tzh_typecnt, tzh_charcnt; |
| 2405 | skip_reserve(inf); |
| 2406 | load_counts(inf, tzh_ttisgmtcnt, tzh_ttisstdcnt, tzh_leapcnt, |
| 2407 | tzh_timecnt, tzh_typecnt, tzh_charcnt); |
| 2408 | if (v == 0) |
| 2409 | { |
| 2410 | load_data<int32_t>(inf, tzh_leapcnt, tzh_timecnt, tzh_typecnt, tzh_charcnt); |
| 2411 | } |
| 2412 | else |
| 2413 | { |
| 2414 | #if !defined(NDEBUG) |
| 2415 | inf.ignore((4+1)*tzh_timecnt + 6*tzh_typecnt + tzh_charcnt + 8*tzh_leapcnt + |
| 2416 | tzh_ttisstdcnt + tzh_ttisgmtcnt); |
| 2417 | load_header(inf); |
| 2418 | auto v2 = load_version(inf); |
| 2419 | assert(v == v2); |
| 2420 | skip_reserve(inf); |
| 2421 | #else // defined(NDEBUG) |
| 2422 | inf.ignore((4+1)*tzh_timecnt + 6*tzh_typecnt + tzh_charcnt + 8*tzh_leapcnt + |
| 2423 | tzh_ttisstdcnt + tzh_ttisgmtcnt + (4+1+15)); |
| 2424 | #endif // defined(NDEBUG) |
| 2425 | load_counts(inf, tzh_ttisgmtcnt, tzh_ttisstdcnt, tzh_leapcnt, |
| 2426 | tzh_timecnt, tzh_typecnt, tzh_charcnt); |
| 2427 | load_data<int64_t>(inf, tzh_leapcnt, tzh_timecnt, tzh_typecnt, tzh_charcnt); |
| 2428 | } |
| 2429 | #if !MISSING_LEAP_SECONDS |
| 2430 | if (tzh_leapcnt > 0) |
| 2431 | { |
| 2432 | auto& leap_seconds = get_tzdb_list().front().leap_seconds; |
| 2433 | auto itr = leap_seconds.begin(); |
| 2434 | auto l = itr->date(); |
| 2435 | seconds leap_count{0}; |
| 2436 | for (auto t = std::upper_bound(transitions_.begin(), transitions_.end(), l, |
| 2437 | [](const sys_seconds& x, const transition& ct) |
| 2438 | { |
| 2439 | return x < ct.timepoint; |
| 2440 | }); |
| 2441 | t != transitions_.end(); ++t) |
| 2442 | { |
| 2443 | while (t->timepoint >= l) |
| 2444 | { |
| 2445 | ++leap_count; |
| 2446 | if (++itr == leap_seconds.end()) |
| 2447 | l = sys_days(max_year/max_day); |
| 2448 | else |
| 2449 | l = itr->date() + leap_count; |
no test coverage detected