| ... | @@ -13,7 +13,6 @@ pub const DateTime = struct { | ... | @@ -13,7 +13,6 @@ pub const DateTime = struct { |
| 13 | years: u16, | 13 | years: u16, |
| 14 | timezone: TimeZone, | 14 | timezone: TimeZone, |
| 15 | weekday: WeekDay, | 15 | weekday: WeekDay, |
| 16 | era: Era, | | |
| 17 | | 16 | |
| 18 | const Self = @This(); | 17 | const Self = @This(); |
| 19 | | 18 | |
| ... | @@ -50,7 +49,6 @@ pub const DateTime = struct { | ... | @@ -50,7 +49,6 @@ pub const DateTime = struct { |
| 50 | .years = 1970, | 49 | .years = 1970, |
| 51 | .timezone = .UTC, | 50 | .timezone = .UTC, |
| 52 | .weekday = .Thu, | 51 | .weekday = .Thu, |
| 53 | .era = .AD, | | |
| 54 | }; | 52 | }; |
| 55 | | 53 | |
| 56 | pub fn eql(self: Self, other: Self) bool { | 54 | pub fn eql(self: Self, other: Self) bool { |
| ... | @@ -271,7 +269,7 @@ pub const DateTime = struct { | ... | @@ -271,7 +269,7 @@ pub const DateTime = struct { |
| 271 | .YYY => try writer.print("{}", .{self.years}), | 269 | .YYY => try writer.print("{}", .{self.years}), |
| 272 | .YYYY => try writer.print("{:0>4}", .{self.years}), | 270 | .YYYY => try writer.print("{:0>4}", .{self.years}), |
| 273 | | 271 | |
| 274 | .N => try writer.writeAll(@tagName(self.era)), | 272 | .N => try writer.writeAll(@tagName(self.era())), |
| 275 | .NN => try writer.writeAll("Anno Domini"), | 273 | .NN => try writer.writeAll("Anno Domini"), |
| 276 | | 274 | |
| 277 | .A => try printLongName(writer, self.hours / 12, &[_]string{ "AM", "PM" }), | 275 | .A => try printLongName(writer, self.hours / 12, &[_]string{ "AM", "PM" }), |
| ... | @@ -388,6 +386,11 @@ pub const DateTime = struct { | ... | @@ -388,6 +386,11 @@ pub const DateTime = struct { |
| 388 | .ms = self.toUnixMilli() - other_in_the_past.toUnixMilli(), | 386 | .ms = self.toUnixMilli() - other_in_the_past.toUnixMilli(), |
| 389 | }; | 387 | }; |
| 390 | } | 388 | } |
| | 389 | |
| | 390 | pub fn era(self: Self) Era { |
| | 391 | if (self.years >= 0) return .AD; |
| | 392 | @compileError("TODO"); |
| | 393 | } |
| 391 | }; | 394 | }; |
| 392 | | 395 | |
| 393 | pub const format = struct { | 396 | pub const format = struct { |