Switch dates from i128 to u64
I was making them unnecessarily large by accidentally storing them as microseconds instead of milliseconds. Might be able to get away with seconds in the future
This commit is contained in:
parent
65136a44d6
commit
cb89a3e6f3
5 changed files with 7 additions and 7 deletions
|
|
@ -17,8 +17,8 @@
|
|||
// internet connectivity.
|
||||
.dependencies = .{
|
||||
.jetzig = .{
|
||||
.url = "https://github.com/jetzig-framework/jetzig/archive/86d82026ab574d4e5c3c6cc3817dda84b510001a.tar.gz",
|
||||
.hash = "jetzig-0.0.0-IpAgLTkzDwDKmsY9MqM41EHDXWGkViiECa0lzV8xl17x",
|
||||
.url = "https://github.com/jetzig-framework/jetzig/archive/1feb18fb74e626fe068ec67532318640a9cb83be.tar.gz",
|
||||
.hash = "jetzig-0.0.0-IpAgLfMzDwDyAqZ05btcLDd9dfE_bxUbfOI_Wx7a19ed",
|
||||
},
|
||||
.zeit = .{
|
||||
.url = "https://github.com/rockorager/zeit/archive/refs/heads/main.tar.gz",
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig
|
|||
.artists_track = track_artist_name_buffer,
|
||||
.album = item.getT(.string, "album") orelse "",
|
||||
.artists_album = album_artist_name_buffer,
|
||||
.date = @as(u64, @bitCast(@as(i64, @truncate(item.getT(.integer, "date").? * 1000)))),
|
||||
.date = @as(u64, @bitCast(@as(i64, @truncate(item.getT(.integer, "date").?)))),
|
||||
};
|
||||
|
||||
var id_prehash = std.ArrayList(u8).init(allocator);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub fn index(request: *jetzig.Request) !jetzig.View {
|
|||
try scrobble_view.put("album_name", scrobble.album_name);
|
||||
try scrobble_view.put("album_id", scrobble.album_id);
|
||||
var date = std.ArrayList(u8).init(request.allocator);
|
||||
try (try zeit.instant(.{ .source = .{ .unix_timestamp = @divFloor(scrobble.date, 1_000_000) } })).time().strftime(date.writer(), "%d %b %Y, %H:%M");
|
||||
try (try zeit.instant(.{ .source = .{ .unix_timestamp = @divFloor(scrobble.date, 1_000) } })).time().strftime(date.writer(), "%d %b %Y, %H:%M");
|
||||
try scrobble_view.put("date", date.items);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
|
|||
.track = scrobble.master_metadata_track_name.?,
|
||||
.album = scrobble.master_metadata_album_album_name.?,
|
||||
.artist = scrobble.master_metadata_album_artist_name.?,
|
||||
.date = (try zeit.instant(.{ .source = .{ .iso8601 = scrobble.ts } })).unixTimestamp() * 1000,
|
||||
.date = @as(u64, @bitCast((try zeit.instant(.{ .source = .{ .iso8601 = scrobble.ts } })).unixTimestamp() * 1000)),
|
||||
};
|
||||
|
||||
const formatted_scrobble = if (rule_list) |rl|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pub const ImportedScrobble = struct {
|
|||
track: []const u8,
|
||||
artist: []const u8,
|
||||
album: []const u8 = "",
|
||||
date: i128,
|
||||
date: u64,
|
||||
};
|
||||
|
||||
pub const Scrobble = struct {
|
||||
|
|
@ -10,7 +10,7 @@ pub const Scrobble = struct {
|
|||
artists_track: []const []const u8,
|
||||
album: []const u8 = "",
|
||||
artists_album: []const []const u8,
|
||||
date: i128,
|
||||
date: u64,
|
||||
};
|
||||
|
||||
// From lastfmstats.com
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue