~gpanders/zet

3cb440763386792d6a1ceb478b6db7f8804c07a1 — Greg Anders 13 days ago e506d6d
Remove hasExtension function in favor of mem.endsWith
1 files changed, 1 insertions(+), 11 deletions(-)

M src/zettel.zig
M src/zettel.zig => src/zettel.zig +1 -11
@@ 191,7 191,7 @@ pub fn getZettels(allocator: *mem.Allocator) ![]Zettel {

    var it = dir.iterate();
    while (try it.next()) |entry| {
        if (!hasId(entry.name) or !hasExtension(entry.name)) {
        if (!hasId(entry.name) or !mem.endsWith(u8, entry.name, extension)) {
            continue;
        }



@@ 317,16 317,6 @@ test "hasId" {
    std.testing.expect(!hasId(" 20200512074730-test" ++ extension));
}

fn hasExtension(name: []const u8) bool {
    if (name.len < extension.len) return false;
    return mem.eql(u8, name[name.len - extension.len ..], extension);
}

test "hasExtension" {
    std.testing.expect(hasExtension("test" ++ extension));
    std.testing.expect(!hasExtension("test"));
}

fn strftime(allocator: *mem.Allocator, format: [:0]const u8) ![]const u8 {
    var t = c.time(0);
    var tmp = c.localtime(&t);