This is an automated email from the ASF dual-hosted git repository.

jonnybot pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy-geb.git

commit c7d34ba71a7554ce2808c9d7e9355ce66d547057
Author: Adam Pounder <[email protected]>
AuthorDate: Sun Nov 17 10:55:37 2024 +0000

    Remove warning, rename method, tidy formatting
---
 gradle/codenarc/rulesets.groovy                    |  3 +++
 .../groovy/geb/module/DateTimeLocalInput.groovy    | 24 ++++++++++------------
 .../geb/module/DateTimeLocalInputSpec.groovy       |  2 +-
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/gradle/codenarc/rulesets.groovy b/gradle/codenarc/rulesets.groovy
index cc1f2396..0d1342f9 100644
--- a/gradle/codenarc/rulesets.groovy
+++ b/gradle/codenarc/rulesets.groovy
@@ -167,6 +167,9 @@ ruleset {
         UnnecessarySemicolon {
             doNotApplyToFileNames = 'PageOrientedSpec.groovy, 
StrongTypingSpec.groovy'
         }
+        UnnecessaryReturnKeyword {
+            enabled = false
+        }
     }
     ruleset('rulesets/unused.xml')
 }
\ No newline at end of file
diff --git 
a/module/geb-core/src/main/groovy/geb/module/DateTimeLocalInput.groovy 
b/module/geb-core/src/main/groovy/geb/module/DateTimeLocalInput.groovy
index cef76fff..6ffb92dd 100644
--- a/module/geb-core/src/main/groovy/geb/module/DateTimeLocalInput.groovy
+++ b/module/geb-core/src/main/groovy/geb/module/DateTimeLocalInput.groovy
@@ -26,6 +26,7 @@ import static java.time.temporal.ChronoField.*
 @Slf4j
 class DateTimeLocalInput extends AbstractInput {
 
+    /* codenarc-disable */
     private static final DateTimeFormatter DATE_TIME_FORMAT = new 
DateTimeFormatterBuilder()
             .append(DateTimeFormatter.ISO_LOCAL_DATE)
             .appendLiteral('T')
@@ -36,15 +37,22 @@ class DateTimeLocalInput extends AbstractInput {
             .appendValue(SECOND_OF_MINUTE, 2)
             .appendFraction(MILLI_OF_SECOND, 0, 3, true)
             .toFormatter()
-    
+    /* codenarc-enable */
+
     final String inputType = 'datetime-local'
 
     void setDateTime(LocalDateTime dateTime) {
-        value(reformat(dateTime))
+        value(formatForBrowser(dateTime))
+    }
+
+    // codenarc-disable StaticMethodsBeforeInstanceMethods
+    static String formatForBrowser(LocalDateTime localDateTime) {
+        return localDateTime.format(DATE_TIME_FORMAT)
     }
+    // codenarc-enable
 
     void setDateTime(String iso8601FormattedDateTime) {
-        setDateTime(LocalDateTime.parse(iso8601FormattedDateTime))
+        dateTime = LocalDateTime.parse(iso8601FormattedDateTime)
     }
 
     LocalDateTime getDateTime() {
@@ -56,14 +64,4 @@ class DateTimeLocalInput extends AbstractInput {
     protected boolean isTypeValid(String type) {
         super.isTypeValid(type) || type == "text"
     }
-
-    private static String reformat(LocalDateTime localDateTime) {
-        String inputValue = localDateTime.format(DATE_TIME_FORMAT)
-        if(localDateTime.toString() != inputValue) {
-            log.warn("The datetime value {} was truncated to {} as it was 
being used to set the value of a <input type=\"datetime-local\" />",
-                    localDateTime, 
-                    inputValue)
-        }
-        return inputValue
-    }
 }
diff --git 
a/module/geb-core/src/test/groovy/geb/module/DateTimeLocalInputSpec.groovy 
b/module/geb-core/src/test/groovy/geb/module/DateTimeLocalInputSpec.groovy
index 7a0d17fa..a297c9aa 100644
--- a/module/geb-core/src/test/groovy/geb/module/DateTimeLocalInputSpec.groovy
+++ b/module/geb-core/src/test/groovy/geb/module/DateTimeLocalInputSpec.groovy
@@ -76,7 +76,7 @@ class DateTimeLocalInputSpec extends 
GebSpecWithCallbackServer {
         where:
         dateTime = LocalDateTime.now()
     }
-    
+
     private static LocalDateTime truncated(LocalDateTime ldt) {
         return ldt.truncatedTo(ChronoUnit.MILLIS)
     }

Reply via email to