Miscellaneous fixes
This commit is contained in:
parent
9547839328
commit
95c8113136
18
src/main.zig
18
src/main.zig
@ -114,7 +114,7 @@ pub const DateTime = struct {
|
||||
seconds -= 60;
|
||||
minutes -= 1;
|
||||
}
|
||||
const second = @intCast(u6, seconds + 60);
|
||||
const second = @as(u6, @intCast(seconds + 60));
|
||||
return Self{
|
||||
.year = year,
|
||||
.month = month.?,
|
||||
@ -145,15 +145,15 @@ pub const DateTime = struct {
|
||||
return Self{
|
||||
.year = year,
|
||||
.month = month,
|
||||
.day = @intCast(u8, day),
|
||||
.hour = @intCast(u5, hour),
|
||||
.minute = @intCast(u6, minute),
|
||||
.second = @intCast(u6, seconds),
|
||||
.day = @as(u8, @intCast(day)),
|
||||
.hour = @as(u5, @intCast(hour)),
|
||||
.minute = @as(u6, @intCast(minute)),
|
||||
.second = @as(u6, @intCast(seconds)),
|
||||
.tz = .utc,
|
||||
};
|
||||
} else {
|
||||
return Self{
|
||||
.year = Year.new(0),
|
||||
.year = Year.new(1970),
|
||||
.month = .january,
|
||||
.day = 1,
|
||||
.hour = 0,
|
||||
@ -171,7 +171,7 @@ pub const DateTime = struct {
|
||||
pub fn weekday(self: Self) WeekDay {
|
||||
const ts = self.toTimestamp();
|
||||
const days = @divTrunc(ts, SECONDS_PER_DAY);
|
||||
return @intToEnum(WeekDay, @rem(days, 7));
|
||||
return @as(WeekDay, @enumFromInt(@rem(days, 7)));
|
||||
}
|
||||
|
||||
pub fn compare(self: Self, other: Self) Comparison {
|
||||
@ -190,7 +190,7 @@ pub const DateTime = struct {
|
||||
_ = options;
|
||||
|
||||
try writer.print("{s}-{d:0>2}-{d:0>2}", .{
|
||||
self.year, @enumToInt(self.month), self.day,
|
||||
self.year, @intFromEnum(self.month), self.day,
|
||||
});
|
||||
if (self.hour) |h| {
|
||||
try writer.print("T{d:0>2}", .{h});
|
||||
@ -209,7 +209,7 @@ pub const DateTime = struct {
|
||||
writer: anytype,
|
||||
) !void {
|
||||
try writer.print("{s}{d:0>2}{d:0>2}", .{
|
||||
self.year, @enumToInt(self.month), self.day,
|
||||
self.year, @intFromEnum(self.month), self.day,
|
||||
});
|
||||
if (self.hour) |h| {
|
||||
try writer.print("T{d:0>2}", .{h});
|
||||
|
Loading…
Reference in New Issue
Block a user