Skip to content

Add jetstream direct get timestamp parsing#810

Open
oliverlambson wants to merge 1 commit intonats-io:mainfrom
oliverlambson:direct-get-dt
Open

Add jetstream direct get timestamp parsing#810
oliverlambson wants to merge 1 commit intonats-io:mainfrom
oliverlambson:direct-get-dt

Conversation

@oliverlambson
Copy link
Contributor

Closes #809

wallyqs pushed a commit to wallyqs/nats.py that referenced this pull request Jan 26, 2026
Add comprehensive unit tests for the ISO 8601 datetime parsing utility
function introduced in PR nats-io#810. These tests cover:

- Standard UTC timestamps with Z suffix
- Timestamps with microsecond and nanosecond precision
- Fractional second trimming (nanoseconds to microseconds)
- Different timestamp formats (Z vs +00:00 offset)
- Edge cases (midnight, end of day)
- Python version compatibility (< 3.11 vs >= 3.11)

This test file validates the _parse_iso_dt function that enables
js.get_msg(..., direct=True) to properly populate RawStreamMsg.time
from the Nats-Time-Stamp header.
# Trim fractional seconds to 6 digits
date_part, frac_tz = time_string.split(".", 1)
frac, tz = frac_tz.split("+")
frac = frac[:6] # keep only microseconds
Copy link
Contributor Author

@oliverlambson oliverlambson Jan 26, 2026

Choose a reason for hiding this comment

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

i kept this as-is, but it's worth noting the proposed changes to this logic in #796 (i.e., this may contain a pre-existing bug)

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.

js.get_msg(..., direct=True) does not populate RawStreamMsg.time

1 participant