From 414cab840c5eabc45e63d16ed89f4008937c7fc1 Mon Sep 17 00:00:00 2001 From: Helton Reis Date: Thu, 5 Oct 2023 20:51:06 -0300 Subject: [PATCH] feat: use the appropriate method for unix timestamp conversion --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f26ea2b..0f5fee3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -112,9 +112,8 @@ fn ulid_to_uuid(input: ulid) -> Uuid { #[pg_extern(immutable, parallel_safe)] fn ulid_to_timestamp(input: ulid) -> Timestamp { - // 946684800000 is the number of milliseconds between 1970-01-01 and 2000-01-01 - let inner = InnerUlid(input.0).timestamp_ms() as i64 - 946_684_800_000; - Timestamp::try_from(inner * 1000).unwrap() + let inner_seconds = (InnerUlid(input.0).timestamp_ms() as f64) / 1000.0; + to_timestamp(inner_seconds).into() } #[pg_extern(immutable, parallel_safe)]