Skip to content

Mini library for expressing integer time values in more human readable ways

License

Notifications You must be signed in to change notification settings

GoNZooo/zig-humantime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-humantime

This library exports two functions to convert human readable time strings into integer values:

test "1h2m3s" {
    const time = comptime seconds("1h2m3s");
    // @compileLog(time) -> 7446
    testing.expectEqual(time, 3723);
}

test "2h4m6s" {
    const time = comptime seconds("2h4m6s");
    testing.expectEqual(time, (3600 * 2) + (4 * 60) + 6);
}

test "1h2m3s in milliseconds" {
    const format_string = "1h2m3s";
    const time = milliseconds(format_string);
    // @compileLog(time) -> runtime value
    testing.expectEqual(time, comptime seconds(format_string) * 1000);
}

test "5d4h3m2s" {
    testing.expectEqual(seconds("5d4h3m2s"), 446582);
}

About

Mini library for expressing integer time values in more human readable ways

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages