-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes wrong value for microsecs in a day #1849
Fixes wrong value for microsecs in a day #1849
Conversation
pgrx/src/datum/time_with_timezone.rs
Outdated
@@ -24,7 +24,10 @@ use std::panic::{RefUnwindSafe, UnwindSafe}; | |||
#[derive(Debug, Copy, Clone)] | |||
#[repr(transparent)] | |||
pub struct TimeWithTimeZone(pg_sys::TimeTzADT); | |||
const MICROSECONDS_PER_DAY: pg_sys::TimeADT = 86_400_000; | |||
|
|||
// 86_400_000_000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix! Could you mention that it comes from the USECS_PER_DAY
constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, let's reuse that const across datetime module.
Thanks @aykut-bozkurt. Could you add a test for this in the pgrx-tests crate? I believe there’s a module for date/time tests already. |
@@ -24,6 +24,9 @@ mod ops; | |||
|
|||
pub use ctor::*; | |||
|
|||
pub const USECS_PER_SEC: i64 = 1_000_000; | |||
pub const USECS_PER_DAY: i64 = pg_sys::SECS_PER_DAY as i64 * USECS_PER_SEC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eeeebbbbrrrr, why does pg_sys
has SECS_PER_DAY
generated but not USECS_PER_SEC
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm. Probably b/c of how it's defined in timestamp.h
:
#define USECS_PER_SEC INT64CONST(1000000)
Kinda doubt bindgen can see through even that simple of a #define.
I was very tired that week. |
`MICROSECONDS_PER_DAY` constant at `time_with_timezone.rs` misses 3 additional zeros for microseconds part. That breaks conversion from `(pg_sys::TimeADT, i32)` to `TimeWithTimeZone`. Fixes pgcentralfoundation#1850
MICROSECONDS_PER_DAY
constant attime_with_timezone.rs
misses 3 additional zeros for microseconds part.That breaks conversion from
(pg_sys::TimeADT, i32)
toTimeWithTimeZone
.Fixes #1850