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

Fixed the utc_from_timestamp method ,added test cases #60

Merged
merged 5 commits into from
Jun 15, 2024

Conversation

shubhamdixit863
Copy link
Contributor

This Pr fixes the issue

#59

Copy link
Member

@KeranYang KeranYang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think @vigith asked for epoch(0) test. Could you add?

Copy link
Contributor

@yhl25 yhl25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub(crate) fn utc_from_timestamp(t: Option<Timestamp>) -> DateTime<Utc> {
    t.map_or(Utc.timestamp_nanos(-1), |t| {
        DateTime::from_timestamp(t.seconds, t.nanos as u32).unwrap_or(Utc.timestamp_nanos(-1))
    })
}

use this, I have already fixed this issue in my PR

@vigith
Copy link
Member

vigith commented Jun 14, 2024


pub(crate) fn utc_from_timestamp(t: Option<Timestamp>) -> DateTime<Utc> {

    t.map_or(Utc.timestamp_nanos(-1), |t| {

        DateTime::from_timestamp(t.seconds, t.nanos as u32).unwrap_or(Utc.timestamp_nanos(-1))

    })

}

This is the right way to do, mathematical operations shouldn't be done directly on time

@shubhamdixit863
Copy link
Contributor Author

pub(crate) fn utc_from_timestamp(t: Option<Timestamp>) -> DateTime<Utc> {
    t.map_or(Utc.timestamp_nanos(-1), |t| {
        DateTime::from_timestamp(t.seconds, t.nanos as u32).unwrap_or(Utc.timestamp_nanos(-1))
    })
}

use this, I have already fixed this issue in my PR

ok

@yhl25 yhl25 merged commit 7288b17 into numaproj:main Jun 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants