update: inSeconds and inDays

This commit is contained in:
Lucas F. 2026-01-17 16:03:50 -03:00
parent c7d52a0f32
commit 002d2b949e

View file

@ -36,6 +36,21 @@ pub const RelativeDelta = struct {
self.seconds == 0;
}
pub fn inSeconds(self: RelativeDelta) i64 {
return @as(i64, self.years) * 365 * 24 * 60 * 60 +
@as(i64, self.months) * 30 * 24 * 60 * 60 +
@as(i64, self.days) * 24 * 60 * 60 +
@as(i64, self.hours) * 60 * 60 +
@as(i64, self.minutes) * 60 +
@as(i64, self.seconds);
}
pub fn inDays(self: RelativeDelta) i64 {
return @as(i64, self.years) * 365 +
@as(i64, self.months) * 30 +
@as(i64, self.days);
}
pub fn normalize(self: *RelativeDelta) void {
// Normaliza meses anos + meses
if (self.months >= 12 or self.months <= -12) {