Zig 0.17.0-dev (Split by item)

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 library itself.

YearAndDay

epoch.YearAndDay
pub const YearAndDay = struct

File

lib/std/time/epoch.zig:109

Code

pub const YearAndDay = struct {
    year: Year,
    /// The number of days into the year (0 to 365)
    day: u9,

    pub fn calculateMonthDay(self: YearAndDay) MonthAndDay {
        var month: Month = .jan;
        var days_left = self.day;
        while (true) {
            const days_in_month = getDaysInMonth(self.year, month);
            if (days_left < days_in_month)
                break;
            days_left -= days_in_month;
            month = @as(Month, @fromBackingInt(@intCast(@backingInt(month) + 1)));
        }
        return .{ .month = month, .day_index = @as(u5, @intCast(days_left)) };
    }
}