Skip to content
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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pgrx/src/datum/time_with_timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

const MICROSECONDS_PER_DAY: pg_sys::TimeADT = 24 * 60 * 60 * 1000 /* milli */ * 1000 /* micro */;

impl From<TimeWithTimeZone> for pg_sys::TimeTzADT {
#[inline]
fn from(value: TimeWithTimeZone) -> Self {
Expand Down
Loading