Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

parse

Public Function
std.tz.Tz.parse
pub fn parse(allocator: Allocator, reader: *Reader) !Tz

Params

File

tz.zig:63
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
    pub fn parse(allocator: Allocator, reader: *Reader) !Tz {
        const legacy_header = try reader.takeStruct(Header, .big);
        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 (legacy_header.version == 0)
            return parseBlock(allocator, reader, legacy_header, true);

        // If the format is modern, just skip over the legacy data
        const skip_n = 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.discardAll(skip_n);

        var header = try reader.takeStruct(Header, .big);
        if (!std.mem.eql(u8, &header.magic, "TZif")) return error.BadHeader;
        if (header.version != '2' and header.version != '3') return error.BadVersion;

        return parseBlock(allocator, reader, header, false);
    }