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

Formatted dates lose millisecond precision #1

Closed
chriscalo opened this issue May 18, 2022 · 1 comment · Fixed by #2
Closed

Formatted dates lose millisecond precision #1

chriscalo opened this issue May 18, 2022 · 1 comment · Fixed by #2

Comments

@chriscalo
Copy link
Contributor

chriscalo commented May 18, 2022

When using this I noticed all milliseconds in dates get discarded and effectively set to 0.

You can see this in the moment format used, which has only seconds precision:

function formatMoment(m)
{
    return string(m.utc().format('YYYY-MM-DD HH:mm:ss'), false) + '::timestamp with time zone';
}

function formatDate(date)
{
    return formatMoment(moment(date));
}

If I'm reading the moment docs correctly, getting to the desired format should be as simple as appending .SSS after the seconds:

'YYYY-MM-DD HH:mm:ss.SSS'

I don't know how actively maintained this library is. Any hope of this getting fixed and published?

I'd be happy to attempt a fix PR if it's likely to be accepted.

Thanks for giving this some consideration.

Cheers,
Chris

@chriscalo chriscalo changed the title Dates discard millisecond precision Formatted dates lose millisecond precision May 18, 2022
@chriscalo
Copy link
Contributor Author

The change was so small I gave it a shot anyway.

All tests pass locally for me.

Let me know if there's anything you'd like updated.

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 a pull request may close this issue.

1 participant