File tree Expand file tree Collapse file tree 4 files changed +7
-3
lines changed
main/java/com/coditory/quark/config
test/groovy/com/coditory/quark/config/parsing Expand file tree Collapse file tree 4 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 22build
33.gradle
44! gradle /wrapper /gradle-wrapper.jar
5+ .kotlin
56
67# IntelliJ
78out
Original file line number Diff line number Diff line change 11distributionBase =GRADLE_USER_HOME
22distributionPath =wrapper/dists
3- distributionUrl =https\://services.gradle.org/distributions/gradle-8.7 -all.zip
3+ distributionUrl =https\://services.gradle.org/distributions/gradle-8.12 -all.zip
44networkTimeout =10000
55validateDistributionUrl =true
66zipStoreBase =GRADLE_USER_HOME
Original file line number Diff line number Diff line change 66import java .util .regex .Pattern ;
77
88class DurationParser {
9- private static final Pattern pattern = Pattern .compile ("\\ d+(\\ .\\ d+)? *(ms|s|m|h)" );
9+ private static final Pattern pattern = Pattern .compile ("\\ d+(\\ .\\ d+)? *(ms|s|m|h|d )" );
1010
1111 static Duration parseDuration (String value ) {
1212 if (value .startsWith ("-P" ) || value .startsWith ("P" )) {
@@ -20,6 +20,9 @@ static Duration parseDuration(String value) {
2020 if (unit .equals ("MS" )) {
2121 unit = "S" ;
2222 durationNumber = durationNumber / 1000 ;
23+ } else if (unit .equals ("D" )) {
24+ unit = "H" ;
25+ durationNumber = durationNumber * 24 ;
2326 }
2427 return durationNumber % 1 == 0
2528 ? durationParse ("PT" + (int ) durationNumber + unit )
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class DurationParsingSpec extends Specification {
2929 " 1.5s" || Duration . parse(" PT1.5S" )
3030 " 1m" || Duration . parse(" PT1M" )
3131 " 2h" || Duration . parse(" PT2H" )
32+ " 2d" || Duration . parse(" PT48H" )
3233 }
3334
3435 @Unroll
@@ -40,7 +41,6 @@ class DurationParsingSpec extends Specification {
4041 where :
4142 value << [
4243 " 1.5m" ,
43- " 1d" ,
4444 " 10.5mss" ,
4545 " 1.0.5ms"
4646 ]
You can’t perform that action at this time.
0 commit comments