-+ /* Android does not have /etc/localtime but uses a system property for the
-+ the current timezone. There are no files under /usr/share/zoneinfo,
-+ instead a single /system/usr/share/zoneinfo/tzdata which are all zoneinfo
-+ files compiled together with the following tool:
-+ https://android.googlesource.com/platform/external/icu/+/master/tools/ZoneCompactor.java */
-+ struct tzdata_header {
-+ char version[12];
-+ uint32_t index_offset, data_offset, zonetab_offset;
-+ } __attribute__((packed)) header;
-+
-+ struct tzdata_index_entry {
-+ char name[40];
-+ uint32_t offset, length, unused;
-+ } __attribute__((packed)) entry;
-+
-+ if (identifier == NULL) {
-+ char sys_timezone[PROP_VALUE_MAX];
-+ if (__system_property_get("persist.sys.timezone", sys_timezone) < 1) {
-+ g_warning("__system_property_get(\"persist.sys.timezone\") failed\n");
++/* Android uses a 'persist.sys.timezone' system property for the
++ * current timezone instead of a /etc/localtime file:
++ * https://android.googlesource.com/platform/ndk/+/android-2.2_r1/docs/system/libc/OVERVIEW.TXT#67
++ *
++ * There are no files under /usr/share/zoneinfo - instead a single
++ * /system/usr/share/zoneinfo/tzdata file is used which contains all
++ * files compiled together with the following tool:
++ * https://android.googlesource.com/platform/system/timezone/+/master/zone_compactor/main/java/ZoneCompactor.java
++ */
++static GBytes *
++zone_info_android (const gchar *identifier)
++{
++ char sys_timezone[PROP_VALUE_MAX];
++ GMappedFile *file;
++ gchar *tzdata;
++ gsize tzdata_length;
++ const gsize index_entry_size = 52;
++ gint32 header_index_offset, header_data_offset;
++ gint32 entry_count, current_index;
++ char* entry_name;
++ gint32 entry_offset, entry_length;
++ guint32 entry_name_start, entry_name_end;
++ guint32 zoneinfo_start, zoneinfo_end;
++ GBytes *zoneinfo;
++ GError *error = NULL;
++
++ if (identifier == NULL)
++ {
++ if (__system_property_get ("persist.sys.timezone", sys_timezone) < 1)
++ {
++ g_warning ("__system_property_get(\"persist.sys.timezone\") failed");
++ return NULL;
++ }
++ identifier = sys_timezone;
++ }
++
++ file = g_mapped_file_new ("/system/usr/share/zoneinfo/tzdata", FALSE, &error);
++ if (file == NULL)
++ {
++ g_warning ("Failed mapping tzdata file: %s", error->message);
++ g_error_free (error);