feat(clp-s::timestamp_parser): Add support for preserving leap seconds in date-time timestamps.#1673
Conversation
WalkthroughAdds leap-second support: introduces Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
components/core/src/clp_s/timestamp_parser/TimestampParser.cpp(7 hunks)components/core/src/clp_s/timestamp_parser/TimestampParser.hpp(2 hunks)components/core/src/clp_s/timestamp_parser/test/test_TimestampParser.cpp(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
⚙️ CodeRabbit configuration file
- Prefer
false == <expression>rather than!<expression>.
Files:
components/core/src/clp_s/timestamp_parser/TimestampParser.hppcomponents/core/src/clp_s/timestamp_parser/test/test_TimestampParser.cppcomponents/core/src/clp_s/timestamp_parser/TimestampParser.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: ubuntu-jammy-static-linked-bins
- GitHub Check: ubuntu-jammy-dynamic-linked-bins
- GitHub Check: ubuntu-jammy-lint
- GitHub Check: centos-stream-9-static-linked-bins
- GitHub Check: centos-stream-9-dynamic-linked-bins
- GitHub Check: musllinux_1_2-x86_64-static-linked-bins
- GitHub Check: package-image
- GitHub Check: musllinux_1_2-x86_64-dynamic-linked-bins
- GitHub Check: manylinux_2_28-x86_64-static-linked-bins
- GitHub Check: manylinux_2_28-x86_64-dynamic-linked-bins
- GitHub Check: conventional-commits
- GitHub Check: lint-check (macos-15)
- GitHub Check: lint-check (ubuntu-24.04)
- GitHub Check: build-macos (macos-15, false)
- GitHub Check: build-macos (macos-15, true)
🔇 Additional comments (9)
components/core/src/clp_s/timestamp_parser/TimestampParser.hpp (1)
109-110: LGTM! Documentation updates are clear and consistent.The updated specifier documentation correctly reflects the new leap-second handling:
\Snow limited to 00-59\Jfor leap second value 60\sas a generic CAT sequence that resolves to either\Sor\JAlso applies to: 128-128
components/core/src/clp_s/timestamp_parser/test/test_TimestampParser.cpp (3)
255-259: LGTM! Test coverage for seconds specifiers is comprehensive.The test correctly validates:
\Saccepts only 00-59\Jaccepts only 60 (leap second)
412-420: LGTM! Generic second transformation tests cover all edge cases.Good coverage of boundary conditions: 00, 01, 58, 59 map to
\S, and 60 maps to\J.
513-516: LGTM! Leap second parsing tests verify correct epoch time mapping.The tests appropriately verify that:
23:59:59and23:59:60map to the same epoch nanoseconds (as leap seconds are stored as second 59)00:00:00on the next day has the expected epoch timecomponents/core/src/clp_s/timestamp_parser/TimestampParser.cpp (5)
44-45: LGTM! Constant definitions are clear and well-named.Good separation between the maximum regular second (59) and the leap second value (60).
116-137: LGTM! Default patterns correctly updated to use generic second specifier.Using
\sinstead of\Senables automatic leap-second detection across all default date-time patterns.
632-635: LGTM! Leap second marshalling outputs the correct value.The
'J'specifier correctly outputs60for the leap second.
850-852: LGTM! New specifiers correctly registered in pattern creation.Both
'J'(leap second) and's'(generic second) are properly marked as requiring date-type representation.Also applies to: 904-906
1219-1238: LGTM! Leap second parsing logic is correct.The
'J'specifier correctly:
- Validates that the parsed value is exactly 60
- Maps leap second to
cMaxParsedSecond(59) for storage
LinZhihao-723
left a comment
There was a problem hiding this comment.
Overall lgtm. Some nit comments.
| constexpr int cMinParsedSecond{0}; | ||
| constexpr int cMaxParsedSecond{60}; | ||
| constexpr int cMaxParsedSecond{59}; | ||
| constexpr int cParsedLeapSecond{60}; |
Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
LinZhihao-723
left a comment
There was a problem hiding this comment.
For the PR title, how about:
feat(clp-s::timestamp_parser): Add support for preserving leap seconds in date-time timestamps.
Only recourses seem to refer to "leap second" not "leap-second"
…s in date-time timestamps. (y-scope#1673) Co-authored-by: Lin Zhihao <59785146+LinZhihao-723@users.noreply.github.com>
Description
This is the final (for now) PR for implementing the new clp_s::timestamp_parser utility. This PR follows up on #1646, #1626, #1599, #1564, and #1385.
This PR implements support for preserving leap-seconds in date-time timestamps. This is accomplished by:
\Sformat specifier to only accept seconds in the range00-59\Jformat specifier which accepts the second value60, always marshalls the seconds value as60, and parses the seconds value as59(since we store timestamps in epoch nanosecond time, which doesn't count leap-seconds).\sCAT sequence which transforms into\Sor\Jdepending on the seconds value.\sinstead of\S.Note that while this can make timestamps during a leap second and prior to a leap second unordered in epoch time (which is what we store), it is possible to accurately transform each timestamp into UTC time, in which the timestamps are properly ordered.
This solution is explained in more detail in the timestamp parser design doc.
Checklist
breaking change.
Validation performed
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.