diff --git a/build.zig b/build.zig index 3693aef..832daea 100644 --- a/build.zig +++ b/build.zig @@ -17,19 +17,19 @@ pub fn build(b: *std.Build) void { _ = b.addModule( "datetime", .{ - .source_file = .{ - .path = "src/main.zig", - }, + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, }, ); - const lib = b.addStaticLibrary(.{ - .name = "datetime", - .root_source_file = .{ .path = "src/main.zig" }, - .target = target, - .optimize = optimize, - }); - b.installArtifact(lib); + // const lib = b.addStaticLibrary(.{ + // .name = "datetime", + // .root_source_file = .{ .path = "src/main.zig" }, + // .target = target, + // .optimize = optimize, + // }); + // b.installArtifact(lib); const main_tests = b.addTest(.{ .root_source_file = .{ .path = "src/main.zig" }, diff --git a/src/main.zig b/src/main.zig index 4faea76..3b8cee3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1452,9 +1452,8 @@ test "asDateTime" { pub fn isLeap(year: Year) bool { // taken from https://github.com/ziglang/zig/pull/18451 - // In the western Gregorian Calendar leap a year is - // a multiple of 4, excluding multiples of 100, and - // adding multiples of 400. In code: + // In the western Gregorian Calendar leap a year is a multiple of 4, + // excluding multiples of 100, and adding multiples of 400. In code: // // if (@mod(year, 4) != 0) // return false; @@ -1462,14 +1461,12 @@ pub fn isLeap(year: Year) bool { // return true; // return (0 == @mod(year, 400)); - // The following is equivalent to the above - // but uses bitwise operations when testing - // for divisibility, masking with 3 as test - // for multiples of 4 and with 15 as a test - // for multiples of 16. Multiples of 16 and - // 100 are, conveniently, multiples of 400. + // The following is equivalent to the above but uses bitwise operations + // when testing for divisibility, masking with 3 as test for multiples of 4 + // and with 15 as a test for multiples of 16. Multiples of 16 and 100 are, + // conveniently, multiples of 400. - const mask: Year = switch (year % 100) { + const mask: Year = switch (@mod(year, 100)) { 0 => 0b1111, else => 0b11, };