Add date_type and time_type sub-types to stdlib_datetime
Follows up on issue #1147 (https://github.com/fortran-lang/stdlib/issues/1147#issuecomment-4189478629)
I added two new types to make working with dates and times easier:
date_type: For calendar dates only (Year, Month, Day). time_type: For clock times only (Hours, Minutes, Seconds).
Codecov Report
:x: Patch coverage is 92.38965% with 50 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 69.87%. Comparing base (a21a7d6) to head (fcdab92).
:warning: Report is 54 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/datetime/stdlib_datetime.f90 | 82.51% | 50 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #1179 +/- ##
==========================================
+ Coverage 68.81% 69.87% +1.05%
==========================================
Files 408 408
Lines 13726 14374 +648
Branches 1552 1700 +148
==========================================
+ Hits 9446 10044 +598
- Misses 4280 4330 +50
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Hi @jalvesz,
Addressed several datetime issues by enforcing strict ISO date parsing, clamping millisecond values to prevent rounding overflows, and ensuring date arithmetic accounts for full timedelta durations.
Added new regression tests to verify midnight-crossing timezone comparisons and strict string validation, ensuring the module handles edge cases like sub-day components and trailing characters correctly.
@JAi-SATHVIK thank you for this PR. However, Github shows commits that are already merged and are older thant this PR. Could you check that, please, to faciliate its review?
Thanks for this PR, looking forward to using it!
One question: is there a reason the pure functions aren't marked elemental? For example day_of_year — I had to write my own wrapper just to apply it over an array:
!! same as day_of_year, but elemental
pure elemental function elemental_day_of_year(dt) result(doy)
type(datetime_type), intent(in) :: dt
integer :: doy
doy = day_of_year(dt)
end function elemental_day_of_year
I don't see an obvious reason why they couldn't be elemental, but maybe I'm missing something?
Agree @cyrilgandon I would advise to make any function that can be elemental, made elemental.