From d0a2fcbcca1a7d7be1970240ddaa2bc7bf1cdc54 Mon Sep 17 00:00:00 2001 From: Sylphrena Date: Mon, 10 Feb 2025 22:22:24 +0100 Subject: [PATCH] Added Time::EpochConverter --- src/db/serializable.cr | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/db/serializable.cr b/src/db/serializable.cr index ce92ca66..f076804e 100644 --- a/src/db/serializable.cr +++ b/src/db/serializable.cr @@ -182,3 +182,15 @@ module DB end end end + +module Time::EpochConverter + def self.from_rs(rs : ::DB::ResultSet) : Time + Time.unix(rs.read.as(Int64)) # This is probably not correct for DBs other than SQLite. + end +end + +module Time::EpochMillisConverter + def self.from_rs(rs : ::DB::ResultSet) : Time + Time.unix_ms(rs.read.as(Int64)) # This is probably not correct for DBs other than SQLite. + end +end