Code update for epoch time calculation within DateTimeConverter and enhances unit test coverage by updating relevant test cases #230
Conversation
…date Follow up PR for eclipse-score#135 Summary This PR fixes inaccuracies in epoch time calculation within DateTimeConverter and enhances unit test coverage by adding relevant test cases. Changes Fixed off-by-one issue in date calculation Removed incorrect leap year adjustment logic Improved epoch conversion accuracy Updated and aligned unit test cases Performed minor code cleanup Root Cause The previous implementation applied incorrect leap year adjustments and had boundary condition issues, leading to inaccurate epoch calculations. Testing Validated using updated unit tests Verified edge cases for date conversion and leap-year handling Impact Improves correctness of DateTimeConverter calculations Strengthens validation through better test coverage No impact on external interfaces
|
The created documentation from the pull request is available at: docu-html |
There was a problem hiding this comment.
Pull request overview
This PR updates score::common::DateTimeConverter logic to improve epoch/date conversion correctness (notably around year boundaries and pre-1970 normalization) and adds new unit tests to cover additional validation and boundary scenarios.
Changes:
- Refactored date validation to use a shared
daysInMonth()helper and removed a pre-1970 leap-year adjustment branch. - Adjusted
epochToDateTime()year-boundary logic and added explicit month/year rollover handling when pre-1970 time normalization increments the day. - Added unit tests for invalid inputs and for specific post-/pre-1970 boundary cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| score/datetime_converter/datetime_converter.cpp | Adds daysInMonth() helper, updates date validation, and adjusts pre/post-1970 epoch→DateTime conversion edge handling. |
| score/datetime_converter/datetime_converter_test.cpp | Adds new negative/edge-case tests for validation, rollover boundaries, and out-of-range epoch behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
@gierer : is anything else I should update for this PR? |
|
Formatting checks fail. The Followup PR https://github.com/eclipse-score/baselibs/pull/135 mentioned in the description does not exist. |
@paulquiring : working on formatting checks. link for followup PR : [https://github.com//pull/135] Should I update in the description as well? |
Summary
This PR fixes inaccuracies in epoch time calculation within DateTimeConverter and enhances unit test coverage by adding relevant test cases.
Followup PR https://github.com/eclipse-score/baselibs/pull/135
Changes
Root Cause
The previous implementation applied incorrect leap year adjustments and had boundary condition issues, leading to inaccurate epoch calculations.
Testing
Impact