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.
Zig › std/ › crypto/ › Certificate.zig › Date
Date
Certificate.Date
const Date = struct
File
Code
const Date = struct {
year : u16 ,
month : u8 ,
day : u8 ,
hour : u8 ,
minute : u8 ,
second : u8 ,
pub fn toSeconds (date : Date ) u64 {
var sec : u64 = 0 ;
{
var year : u16 = 1970 ;
while (year < date .year ) : (year += 1 ) {
const days : u64 = std .time .epoch .getDaysInYear (year );
sec += days * std .time .epoch .secs_per_day ;
}
}
{
var month : u4 = 1 ;
while (month < date .month ) : (month += 1 ) {
const days : u64 = std .time .epoch .getDaysInMonth (
date .year ,
@fromBackingInt (@intCast (month )),
);
sec += days * std .time .epoch .secs_per_day ;
}
}
sec += (date .day - 1 ) * @as (u64 , std .time .epoch .secs_per_day );
sec += date .hour * @as (u64 , 60 * 60 );
sec += date .minute * @as (u64 , 60 );
sec += date .second ;
return sec ;
}
}