fix zig breakage

This commit is contained in:
Jeffrey C. Ollie 2024-03-13 18:14:00 -05:00
parent 40fc6a8d41
commit 1bbdcd3e40
Signed by: jeff
GPG key ID: 6F86035A6D97044E
2 changed files with 17 additions and 20 deletions

View file

@ -17,19 +17,19 @@ pub fn build(b: *std.Build) void {
_ = b.addModule( _ = b.addModule(
"datetime", "datetime",
.{ .{
.source_file = .{ .root_source_file = .{ .path = "src/main.zig" },
.path = "src/main.zig", .target = target,
}, .optimize = optimize,
}, },
); );
const lib = b.addStaticLibrary(.{ // const lib = b.addStaticLibrary(.{
.name = "datetime", // .name = "datetime",
.root_source_file = .{ .path = "src/main.zig" }, // .root_source_file = .{ .path = "src/main.zig" },
.target = target, // .target = target,
.optimize = optimize, // .optimize = optimize,
}); // });
b.installArtifact(lib); // b.installArtifact(lib);
const main_tests = b.addTest(.{ const main_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" }, .root_source_file = .{ .path = "src/main.zig" },

View file

@ -1452,9 +1452,8 @@ test "asDateTime" {
pub fn isLeap(year: Year) bool { pub fn isLeap(year: Year) bool {
// taken from https://github.com/ziglang/zig/pull/18451 // taken from https://github.com/ziglang/zig/pull/18451
// In the western Gregorian Calendar leap a year is // In the western Gregorian Calendar leap a year is a multiple of 4,
// a multiple of 4, excluding multiples of 100, and // excluding multiples of 100, and adding multiples of 400. In code:
// adding multiples of 400. In code:
// //
// if (@mod(year, 4) != 0) // if (@mod(year, 4) != 0)
// return false; // return false;
@ -1462,14 +1461,12 @@ pub fn isLeap(year: Year) bool {
// return true; // return true;
// return (0 == @mod(year, 400)); // return (0 == @mod(year, 400));
// The following is equivalent to the above // The following is equivalent to the above but uses bitwise operations
// but uses bitwise operations when testing // when testing for divisibility, masking with 3 as test for multiples of 4
// for divisibility, masking with 3 as test // and with 15 as a test for multiples of 16. Multiples of 16 and 100 are,
// for multiples of 4 and with 15 as a test // conveniently, multiples of 400.
// 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, 0 => 0b1111,
else => 0b11, else => 0b11,
}; };