Skip to content

Add LocalDate and sub-second precision support.#10

Merged
gustavofreze merged 6 commits into
mainfrom
feature/develop
May 23, 2026
Merged

Add LocalDate and sub-second precision support.#10
gustavofreze merged 6 commits into
mainfrom
feature/develop

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

@gustavofreze gustavofreze commented May 23, 2026

Please follow the contributing guidelines.

Summary

What this pull request does.

Related issue

Closes #...

Checklist

  • Tests added or updated.
  • Documentation updated when applicable.
  • composer review passes.
  • composer tests passes.

Copilot AI review requested due to automatic review settings May 23, 2026 17:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds two major capabilities to the tiny-blocks Time library: a new LocalDate value object for date-only modeling, and configurable ISO-8601 emission precision for Instant (seconds/milliseconds/microseconds), including decoding of fractional seconds.

Changes:

  • Introduces LocalDate (+ InvalidLocalDate) and documentation/tests for date-only operations and projecting an Instant into a civil date.
  • Adds Precision and extends Instant::toIso8601() to optionally emit milliseconds/microseconds; updates offset datetime decoding to accept fractional seconds.
  • Refactors multiple unit tests toward more explicit Given/When/Then steps and expands Instant coverage for precision formatting.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
tests/Unit/TimezonesTest.php Refactors assertions/BDD step annotations for Timezones.
tests/Unit/TimeOfDayTest.php Refactors assertions/BDD step annotations for TimeOfDay.
tests/Unit/PeriodTest.php Minor refactor of overlap/contains assertions to store intermediate results.
tests/Unit/LocalDateTest.php New comprehensive unit test suite for LocalDate.
tests/Unit/InstantTest.php Adds Precision coverage and more fractional-second parsing/formatting tests.
tests/Unit/DurationTest.php Refactors assertions/BDD steps for Duration comparisons and accessors.
tests/Unit/DayOfWeekTest.php Refactors tests using cases()/array helpers and explicit intermediate variables.
src/Timezones.php PHPDoc wording tweaks for factories and toStrings().
src/Timezone.php PHPDoc wording tweaks for toString() / toDateTimeZone().
src/TimeOfDay.php PHPDoc wording tweaks + renames local $diff to $difference in durationUntil().
src/Precision.php New public enum to represent ISO-8601 emission granularity.
src/LocalDate.php New public value object for date-only operations (parse/format/compare/day arithmetic).
src/Internal/Decoders/OffsetDateTimeDecoder.php Adds fractional-second decoding for offset ISO-8601 instants.
src/Instant.php Adds Precision support in toIso8601() and introduces toLocalDate().
src/Exceptions/InvalidLocalDate.php New exception type for invalid local-date parsing/component validation.
README.md Documents Precision usage and introduces LocalDate section + updates license link.
phpstan.neon.dist Adds a suppression targeting Instant::fromUnixSeconds() return type handling.
.claude/rules/php-library-testing.md Clarifies allowed non-test methods (lifecycle hooks + data providers).
.claude/rules/php-library-code-style.md Updates member-ordering rule semantics and Internal/ PHPDoc guidance.
Comments suppressed due to low confidence (2)

src/Timezones.php:114

  • toStrings() returns a list of IANA identifiers; the summary "Returns the Timezones as strings" is vague compared to the previous wording. Consider restoring the more specific description (identifiers as plain strings) so the PHPDoc matches the return type semantics.
    /**
     * Returns the Timezones as strings.
     *
     * @return list<string> The list of IANA timezone identifier strings.
     */
    public function toStrings(): array

tests/Unit/InstantTest.php:1025

  • This data set calls toIso8601(precision: Precision::Seconds), but Seconds is the method default. Per the code-style rules, default-valued arguments should be omitted; the default behavior is already covered by testToIso8601DefaultPrecisionIsSeconds(). Consider removing this case or switching it to the no-argument call.
            'Seconds precision, no fractions emitted'                 => [
                'value'           => '2026-02-17 08:27:21.106011',
                'precision'       => Precision::Seconds,
                'expectedIso8601' => '2026-02-17T08:27:21+00:00'
            ],

Comment thread src/Instant.php
Comment thread phpstan.neon.dist
Comment thread src/LocalDate.php
Comment thread src/Precision.php
Comment thread src/Internal/Decoders/OffsetDateTimeDecoder.php
Comment thread tests/Unit/PeriodTest.php
Comment thread tests/Unit/DurationTest.php
Comment thread tests/Unit/DayOfWeekTest.php
Comment thread tests/Unit/InstantTest.php
Comment thread README.md
@gustavofreze gustavofreze merged commit bff5ec2 into main May 23, 2026
11 checks passed
@gustavofreze gustavofreze deleted the feature/develop branch May 23, 2026 17:27
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.

2 participants