comment date logging functions so type can be used at comptime

This commit is contained in:
Emil Lerch 2023-09-08 21:38:28 -07:00
parent e8bfd0af6d
commit 2d42bbf464
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -275,9 +275,9 @@ fn secondsBetween(start: DateTime, end: DateTime) DateTimeToTimestampError!i64 {
const leap_years_between = leapYearsBetween(start.year, end.year);
var add_days: u1 = 0;
const years_diff = end.year - start.year;
log.debug("Years from epoch: {d}, Leap years: {d}", .{ years_diff, leap_years_between });
// log.debug("Years from epoch: {d}, Leap years: {d}", .{ years_diff, leap_years_between });
var days_diff: i32 = (years_diff * DAYS_PER_YEAR) + leap_years_between + add_days;
log.debug("Days with leap year, without month: {d}", .{days_diff});
// log.debug("Days with leap year, without month: {d}", .{days_diff});
const seconds_into_year = secondsFromBeginningOfYear(
end.year,
@ -310,15 +310,15 @@ fn secondsFromBeginningOfYear(year: u16, month: u8, day: u8, hour: u8, minute: u
days_diff += days_per_month[current_month - 1]; // months are 1-based vs array is 0-based
current_month += 1;
}
log.debug("Days with month, without day: {d}. Day of month {d}, will add {d} days", .{
days_diff,
day,
day - 1,
});
// log.debug("Days with month, without day: {d}. Day of month {d}, will add {d} days", .{
// days_diff,
// day,
// day - 1,
// });
// We need -1 because we're not actually including the ending day (that's up to hour/minute)
// In other words, days in the month are 1-based, while hours/minutes are zero based
days_diff += day - 1;
log.debug("Total days diff: {d}", .{days_diff});
// log.debug("Total days diff: {d}", .{days_diff});
var seconds_diff: u32 = days_diff * SECONDS_PER_DAY;
// From here out, we want to get everything into seconds
@ -339,7 +339,7 @@ fn leapYearsBetween(start_year_inclusive: u16, end_year_exclusive: u16) u16 {
const start = @min(start_year_inclusive, end_year_exclusive);
const end = @max(start_year_inclusive, end_year_exclusive);
var current = start;
log.debug("Leap years starting from {d}, ending at {d}", .{ start, end });
// log.debug("Leap years starting from {d}, ending at {d}", .{ start, end });
while (current % 4 != 0 and current < end) {
current += 1;
}
@ -349,7 +349,7 @@ fn leapYearsBetween(start_year_inclusive: u16, end_year_exclusive: u16) u16 {
while (current < end) {
if (current % 4 == 0) {
if (current % 100 != 0) {
log.debug("Year {d} is leap year", .{current});
// log.debug("Year {d} is leap year", .{current});
rc += 1;
current += 4;
continue;
@ -357,7 +357,7 @@ fn leapYearsBetween(start_year_inclusive: u16, end_year_exclusive: u16) u16 {
// We're on a century, which is normally not a leap year, unless
// it's divisible by 400
if (current % 400 == 0) {
log.debug("Year {d} is leap year", .{current});
// log.debug("Year {d} is leap year", .{current});
rc += 1;
}
}