| ... | @@ -37,7 +37,7 @@ pub const DateTime = struct { | ... | @@ -37,7 +37,7 @@ pub const DateTime = struct { |
| 37 | } | 37 | } |
| 38 | | 38 | |
| 39 | pub fn now() Self { | 39 | pub fn now() Self { |
| 40 | return initUnixMs(@intCast(u64, std.time.milliTimestamp())); | 40 | return initUnixMs(@intCast(std.time.milliTimestamp())); |
| 41 | } | 41 | } |
| 42 | | 42 | |
| 43 | pub const epoch_unix = Self{ | 43 | pub const epoch_unix = Self{ |
| ... | @@ -68,28 +68,28 @@ pub const DateTime = struct { | ... | @@ -68,28 +68,28 @@ pub const DateTime = struct { |
| 68 | pub fn addMs(self: Self, count: u64) Self { | 68 | pub fn addMs(self: Self, count: u64) Self { |
| 69 | if (count == 0) return self; | 69 | if (count == 0) return self; |
| 70 | var result = self; | 70 | var result = self; |
| 71 | result.ms += @intCast(u16, count % 1000); | 71 | result.ms += @intCast(count % 1000); |
| 72 | return result.addSecs(count / 1000); | 72 | return result.addSecs(count / 1000); |
| 73 | } | 73 | } |
| 74 | | 74 | |
| 75 | pub fn addSecs(self: Self, count: u64) Self { | 75 | pub fn addSecs(self: Self, count: u64) Self { |
| 76 | if (count == 0) return self; | 76 | if (count == 0) return self; |
| 77 | var result = self; | 77 | var result = self; |
| 78 | result.seconds += @intCast(u16, count % 60); | 78 | result.seconds += @intCast(count % 60); |
| 79 | return result.addMins(count / 60); | 79 | return result.addMins(count / 60); |
| 80 | } | 80 | } |
| 81 | | 81 | |
| 82 | pub fn addMins(self: Self, count: u64) Self { | 82 | pub fn addMins(self: Self, count: u64) Self { |
| 83 | if (count == 0) return self; | 83 | if (count == 0) return self; |
| 84 | var result = self; | 84 | var result = self; |
| 85 | result.minutes += @intCast(u16, count % 60); | 85 | result.minutes += @intCast(count % 60); |
| 86 | return result.addHours(count / 60); | 86 | return result.addHours(count / 60); |
| 87 | } | 87 | } |
| 88 | | 88 | |
| 89 | pub fn addHours(self: Self, count: u64) Self { | 89 | pub fn addHours(self: Self, count: u64) Self { |
| 90 | if (count == 0) return self; | 90 | if (count == 0) return self; |
| 91 | var result = self; | 91 | var result = self; |
| 92 | result.hours += @intCast(u16, count % 24); | 92 | result.hours += @intCast(count % 24); |
| 93 | return result.addDays(count / 24); | 93 | return result.addDays(count / 24); |
| 94 | } | 94 | } |
| 95 | | 95 | |
| ... | @@ -132,7 +132,7 @@ pub const DateTime = struct { | ... | @@ -132,7 +132,7 @@ pub const DateTime = struct { |
| 132 | result.days = 0; | 132 | result.days = 0; |
| 133 | result.incrementWeekday(left); | 133 | result.incrementWeekday(left); |
| 134 | } | 134 | } |
| 135 | result.days += @intCast(u16, input); | 135 | result.days += @intCast(input); |
| 136 | result.incrementWeekday(input); | 136 | result.incrementWeekday(input); |
| 137 | | 137 | |
| 138 | if (result.months == 12) { | 138 | if (result.months == 12) { |
| ... | @@ -187,7 +187,7 @@ pub const DateTime = struct { | ... | @@ -187,7 +187,7 @@ pub const DateTime = struct { |
| 187 | pub fn dayOfThisYear(self: Self) u16 { | 187 | pub fn dayOfThisYear(self: Self) u16 { |
| 188 | var ret: u16 = 0; | 188 | var ret: u16 = 0; |
| 189 | for (0..self.months) |item| { | 189 | for (0..self.months) |item| { |
| 190 | ret += self.daysInMonth(@intCast(u16, item)); | 190 | ret += self.daysInMonth(@intCast(item)); |
| 191 | } | 191 | } |
| 192 | ret += self.days; | 192 | ret += self.days; |
| 193 | return ret; | 193 | return ret; |
| ... | @@ -211,8 +211,8 @@ pub const DateTime = struct { | ... | @@ -211,8 +211,8 @@ pub const DateTime = struct { |
| 211 | fn daysSinceEpoch(self: Self) u64 { | 211 | fn daysSinceEpoch(self: Self) u64 { |
| 212 | var res: u64 = 0; | 212 | var res: u64 = 0; |
| 213 | res += self.days; | 213 | res += self.days; |
| 214 | for (0..self.years - epoch_unix.years) |i| res += time.daysInYear(@intCast(u16, i)); | 214 | for (0..self.years - epoch_unix.years) |i| res += time.daysInYear(@intCast(i)); |
| 215 | for (0..self.months) |i| res += self.daysInMonth(@intCast(u16, i)); | 215 | for (0..self.months) |i| res += self.daysInMonth(@intCast(i)); |
| 216 | return res; | 216 | return res; |
| 217 | } | 217 | } |
| 218 | | 218 | |
| ... | @@ -254,13 +254,13 @@ pub const DateTime = struct { | ... | @@ -254,13 +254,13 @@ pub const DateTime = struct { |
| 254 | .DDDo => try printOrdinal(writer, self.dayOfThisYear() + 1), | 254 | .DDDo => try printOrdinal(writer, self.dayOfThisYear() + 1), |
| 255 | .DDDD => try writer.print("{:0>3}", .{self.dayOfThisYear() + 1}), | 255 | .DDDD => try writer.print("{:0>3}", .{self.dayOfThisYear() + 1}), |
| 256 | | 256 | |
| 257 | .d => try writer.print("{}", .{@enumToInt(self.weekday)}), | 257 | .d => try writer.print("{}", .{@intFromEnum(self.weekday)}), |
| 258 | .do => try printOrdinal(writer, @enumToInt(self.weekday)), | 258 | .do => try printOrdinal(writer, @intFromEnum(self.weekday)), |
| 259 | .dd => try writer.writeAll(@tagName(self.weekday)[0..2]), | 259 | .dd => try writer.writeAll(@tagName(self.weekday)[0..2]), |
| 260 | .ddd => try writer.writeAll(@tagName(self.weekday)), | 260 | .ddd => try writer.writeAll(@tagName(self.weekday)), |
| 261 | .dddd => try printLongName(writer, @enumToInt(self.weekday), &[_]string{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }), | 261 | .dddd => try printLongName(writer, @intFromEnum(self.weekday), &[_]string{ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }), |
| 262 | .e => try writer.print("{}", .{@enumToInt(self.weekday)}), | 262 | .e => try writer.print("{}", .{@intFromEnum(self.weekday)}), |
| 263 | .E => try writer.print("{}", .{@enumToInt(self.weekday) + 1}), | 263 | .E => try writer.print("{}", .{@intFromEnum(self.weekday) + 1}), |
| 264 | | 264 | |
| 265 | .w => try writer.print("{}", .{self.dayOfThisYear() / 7 + 1}), | 265 | .w => try writer.print("{}", .{self.dayOfThisYear() / 7 + 1}), |
| 266 | .wo => try printOrdinal(writer, self.dayOfThisYear() / 7 + 1), | 266 | .wo => try printOrdinal(writer, self.dayOfThisYear() / 7 + 1), |