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(
"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" },

View file

@ -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,
};