Skip to content

GROOVY-12124: Modernize the TimeCategory date/time DSL: add a java.ti…#2653

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12124
Open

GROOVY-12124: Modernize the TimeCategory date/time DSL: add a java.ti…#2653
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12124

Conversation

@paulk-asert

@paulk-asert paulk-asert commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

…me flavor and a dequirked java.util.Date flavor

See: https://issues.apache.org/jira/browse/GROOVY-12124

@paulk-asert paulk-asert force-pushed the groovy12124 branch 2 times, most recently from 5cad6b9 to 68b3cba Compare July 2, 2026 05:32
@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.14692% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.5879%. Comparing base (449dfeb) to head (32b5dff).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...he/groovy/dateutil/TimeDatumDependentDuration.java 11.1111% 16 Missing ⚠️
...apache/groovy/dateutil/DatumDependentDuration.java 55.0000% 9 Missing ⚠️
.../java/org/apache/groovy/dateutil/TimeDuration.java 50.0000% 9 Missing ⚠️
.../java/org/apache/groovy/datetime/TimeCategory.java 85.7143% 4 Missing ⚠️
...main/java/org/apache/groovy/dateutil/Duration.java 80.9524% 4 Missing ⚠️
.../java/org/apache/groovy/dateutil/BaseDuration.java 98.5294% 1 Missing ⚠️
.../java/org/apache/groovy/dateutil/TimeCategory.java 97.3684% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2653        +/-   ##
==================================================
+ Coverage     68.5728%   68.5879%   +0.0151%     
- Complexity      33803      33884        +81     
==================================================
  Files            1524       1531         +7     
  Lines          128128     128339       +211     
  Branches        23289      23298         +9     
==================================================
+ Hits            87861      88025       +164     
- Misses          32468      32514        +46     
- Partials         7799       7800         +1     
Files with missing lines Coverage Δ
src/main/java/groovy/time/BaseDuration.java 100.0000% <ø> (ø)
.../main/java/groovy/time/DatumDependentDuration.java 100.0000% <ø> (ø)
src/main/java/groovy/time/Duration.java 100.0000% <ø> (ø)
src/main/java/groovy/time/TimeCategory.java 87.7551% <ø> (ø)
...n/java/groovy/time/TimeDatumDependentDuration.java 100.0000% <ø> (ø)
src/main/java/groovy/time/TimeDuration.java 100.0000% <ø> (ø)
.../java/org/apache/groovy/dateutil/BaseDuration.java 98.5294% <98.5294%> (ø)
.../java/org/apache/groovy/dateutil/TimeCategory.java 97.3684% <97.3684%> (ø)
.../java/org/apache/groovy/datetime/TimeCategory.java 85.7143% <85.7143%> (ø)
...main/java/org/apache/groovy/dateutil/Duration.java 80.9524% <80.9524%> (ø)
... and 3 more

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Introduces modern, “quirk-free” TimeCategory-style DSLs alongside the legacy groovy.time API, addressing GROOVY-12124 by providing:

  • a java.util.Date-flavored DSL in org.apache.groovy.dateutil with deterministic toMilliseconds() and time-of-day-preserving .ago/.from.now
  • a java.time-based DSL in org.apache.groovy.datetime producing native Duration/Period

Changes:

  • Added new org.apache.groovy.dateutil duration/value classes and TimeCategory for Date arithmetic.
  • Added new org.apache.groovy.datetime.TimeCategory DSL for java.time types, with tests and spec docs.
  • Deprecated legacy groovy.time duration/category classes (and marked their test classes deprecated) while keeping them for compatibility.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/TimeCategoryTest.groovy New test suite for the dequirked org.apache.groovy.dateutil.TimeCategory behavior.
subprojects/groovy-dateutil/src/test/groovy/org/apache/groovy/dateutil/DurationTest.groovy New tests for the dequirked org.apache.groovy.dateutil duration hierarchy and arithmetic.
subprojects/groovy-dateutil/src/spec/doc/_working-with-dateutil-types.adoc Adds user-facing documentation for the new number-based Date/Duration DSL.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/TimeDuration.java Introduces the Date-based TimeDuration subtype used by the new DSL.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/TimeDatumDependentDuration.java Introduces mixed duration type for combining time-only and datum-dependent durations.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/TimeCategory.java Adds the new java.util.Date-flavored TimeCategory DSL and Date arithmetic hooks.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/Duration.java Adds the fixed (days-and-below) duration implementation for the new Date DSL.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/DatumDependentDuration.java Adds years/months-capable duration implementation for the new Date DSL.
subprojects/groovy-dateutil/src/main/java/org/apache/groovy/dateutil/BaseDuration.java New shared base implementing deterministic toMilliseconds() and time-preserving relative calculations.
subprojects/groovy-datetime/src/test/groovy/org/apache/groovy/datetime/TimeCategoryTest.groovy New tests for the java.time-based TimeCategory DSL.
subprojects/groovy-datetime/src/spec/doc/_working-with-datetime-types.adoc Adds spec documentation for the java.time DSL (Period/Duration producers and terminals).
subprojects/groovy-datetime/src/main/java/org/apache/groovy/datetime/TimeCategory.java Adds the java.time-native TimeCategory DSL producing Duration and Period.
src/test/groovy/groovy/time/TimeDurationTest.groovy Marks legacy tests deprecated (aligned with legacy API deprecation).
src/test/groovy/groovy/time/TimeDatumDependentDurationTest.groovy Marks legacy tests deprecated (aligned with legacy API deprecation).
src/test/groovy/groovy/time/TimeCategoryTest.groovy Marks legacy tests deprecated (aligned with legacy API deprecation).
src/test/groovy/groovy/time/DurationTest.groovy Marks legacy tests deprecated (aligned with legacy API deprecation).
src/test/groovy/groovy/time/DatumDependentDurationTest.groovy Marks legacy tests deprecated (aligned with legacy API deprecation).
src/main/java/groovy/time/TimeDuration.java Deprecates legacy groovy.time.TimeDuration with pointers to replacements.
src/main/java/groovy/time/TimeDatumDependentDuration.java Deprecates legacy mixed duration type with pointers to replacements.
src/main/java/groovy/time/TimeCategory.java Deprecates legacy TimeCategory with pointers to new Date/java.time alternatives.
src/main/java/groovy/time/Duration.java Deprecates legacy fixed duration class with pointers to replacements.
src/main/java/groovy/time/DatumDependentDuration.java Deprecates legacy datum-dependent duration class with pointers to replacements.
src/main/java/groovy/time/BaseDuration.java Deprecates legacy base duration class with pointers to replacements.

…me flavor and a dequirked java.util.Date flavor
@testlens-app

testlens-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 32b5dff
▶️ Tests: 0 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

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.

3 participants