mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 08:45:54 +03:00
[GH-ISSUE #500] Created-Timestamp should always have a constant number of digits for nanoseconds #325
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#325
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @siom79 on GitHub (May 23, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/500
When looking at the
Createdfield in the/api/v1/messagesAPI, I see different numbers of digits for nanoseconds:The different number of nanoseconds digits causes problems when parsing it for example in Java:
The above will cause an
java.time.format.DateTimeParseException: Text '2025-05-23T13:31:12.24Z' could not be parsed at index 20.Is it possible to always return a constant number of digits?
@axllent commented on GitHub (May 23, 2025):
Hi @siom79. I see your struggle. The "issue" here is that Go's default RFC3339 format includes the fraction of seconds (which Mailpit uses as it can receive hundreds of emails per second). Fractions are however always "trimmed" when they contain trailing zeros. Given that Mailpit stores the messages using UnixMilli, there will only ever be a maximum of 3 decimals, however there can be 2 (as you've seen), 1, or even none at all. I'm not even sure
2025-05-23T13:10:57.600Zis technically valid RFC3339.Rather than try work around the standard RFC3339 (internet time) format which is being used here, have you tried something like this:
"yyyy-MM-dd'T'HH:mm:ss[.SSS]z"? I have absolutely not idea if that works, but if so then you can thank ChatGPT...@siom79 commented on GitHub (May 24, 2025):
Hi, @axllent,
the RFC3339 declares indeed in section 5 that the number of digits is flexible:
As far as I understand this ABNF notation, it means that DIGIT must appear at least once (see here):
So you are right with mailpit and I close this issue. Thanks for your fast feedback.
@axllent commented on GitHub (May 24, 2025):
Super. It would still be very helpful to others however if you can confirm the syntax I suggested works, thanks.
@siom79 commented on GitHub (May 24, 2025):
Unfortunately the square brackets did not work as expected. The following worked: