update: inSeconds and inDays
This commit is contained in:
parent
c7d52a0f32
commit
002d2b949e
1 changed files with 15 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue