Function parse [src]

Prototype

pub fn parse(allocator: std.mem.Allocator, reader: anytype) !Tz

Parameters

allocator: std.mem.Allocator

Source

pub fn parse(allocator: std.mem.Allocator, reader: anytype) !Tz { var legacy_header = try reader.readStruct(Header); if (!std.mem.eql(u8, &legacy_header.magic, "TZif")) return error.BadHeader; if (legacy_header.version != 0 and legacy_header.version != '2' and legacy_header.version != '3') return error.BadVersion; if (builtin.target.cpu.arch.endian() != std.builtin.Endian.big) { std.mem.byteSwapAllFields(@TypeOf(legacy_header.counts), &legacy_header.counts); } if (legacy_header.version == 0) { return parseBlock(allocator, reader, legacy_header, true); } else { // If the format is modern, just skip over the legacy data const skipv = legacy_header.counts.timecnt * 5 + legacy_header.counts.typecnt * 6 + legacy_header.counts.charcnt + legacy_header.counts.leapcnt * 8 + legacy_header.counts.isstdcnt + legacy_header.counts.isutcnt; try reader.skipBytes(skipv, .{}); var header = try reader.readStruct(Header); if (!std.mem.eql(u8, &header.magic, "TZif")) return error.BadHeader; if (header.version != '2' and header.version != '3') return error.BadVersion; if (builtin.target.cpu.arch.endian() != std.builtin.Endian.big) { std.mem.byteSwapAllFields(@TypeOf(header.counts), &header.counts); } return parseBlock(allocator, reader, header, false); } }