You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/09/09 06:35:17 UTC

[isis] branch master updated: ISIS-2869: polishing CalendarEvent

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

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e4a967  ISIS-2869: polishing CalendarEvent
8e4a967 is described below

commit 8e4a967d950ca7bd92e2fe727b716b2b0f7223f3
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Sep 9 08:35:05 2021 +0200

    ISIS-2869: polishing CalendarEvent
---
 .../fullcalendar/applib/value/CalendarEvent.java   | 24 ++++++++++++++++++----
 .../jodatime/applib/value/JodatimeConverters.java  | 12 +++++------
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/extensions/vw/fullcalendar/applib/src/main/java/org/apache/isis/extensions/fullcalendar/applib/value/CalendarEvent.java b/extensions/vw/fullcalendar/applib/src/main/java/org/apache/isis/extensions/fullcalendar/applib/value/CalendarEvent.java
index 6ce1b85..88c9ece 100644
--- a/extensions/vw/fullcalendar/applib/src/main/java/org/apache/isis/extensions/fullcalendar/applib/value/CalendarEvent.java
+++ b/extensions/vw/fullcalendar/applib/src/main/java/org/apache/isis/extensions/fullcalendar/applib/value/CalendarEvent.java
@@ -20,6 +20,7 @@ package org.apache.isis.extensions.fullcalendar.applib.value;
 
 import java.io.Serializable;
 import java.time.Instant;
+import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 
@@ -55,14 +56,29 @@ implements
     private final @NonNull String title;
     private final @Nullable String notes;
 
-    public ZonedDateTime asDateTime(final ZoneId zoneId) {
-        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), zoneId);
+    // -- ADDITIONAL WITHERS
+
+    public CalendarEvent withDateTime(final @NonNull ZonedDateTime dateTime) {
+        return new CalendarEvent(dateTime.toInstant().toEpochMilli(), calendarName, title, notes);
+    }
+
+    public CalendarEvent withDateTime(final @NonNull LocalDateTime localDateTime, final @NonNull ZoneId zoneId) {
+        return withDateTime(ZonedDateTime.of(localDateTime, zoneId));
     }
 
-    public ZonedDateTime asDateTime() {
-        return asDateTime(ZoneId.systemDefault());
+    // -- CONVERTERS
+
+    public ZonedDateTime asDateTime(final @NonNull ZoneId zoneId) {
+        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(epochMillis), zoneId);
     }
 
+    //XXX potential misuse
+//    public ZonedDateTime asDateTime() {
+//        return asDateTime(ZoneId.systemDefault());
+//    }
+
+    // -- OBJECT CONTRACT
+
     @Override
     public int compareTo(final CalendarEvent other) {
         return Long.compare(this.epochMillis, other.getEpochMillis());
diff --git a/valuetypes/jodatime/applib/src/main/java/org/apache/isis/valuetypes/jodatime/applib/value/JodatimeConverters.java b/valuetypes/jodatime/applib/src/main/java/org/apache/isis/valuetypes/jodatime/applib/value/JodatimeConverters.java
index e3fba9d..df24c32 100644
--- a/valuetypes/jodatime/applib/src/main/java/org/apache/isis/valuetypes/jodatime/applib/value/JodatimeConverters.java
+++ b/valuetypes/jodatime/applib/src/main/java/org/apache/isis/valuetypes/jodatime/applib/value/JodatimeConverters.java
@@ -33,7 +33,7 @@ import lombok.experimental.UtilityClass;
 @UtilityClass
 public final class JodatimeConverters {
 
-    // LOCAL TIME
+    // -- INSTANT
 
     public Instant toJoda(final java.time.Instant input) {
         return new Instant(input.toEpochMilli());
@@ -43,7 +43,7 @@ public final class JodatimeConverters {
         return java.time.Instant.ofEpochMilli(input.getMillis());
     }
 
-    // LOCAL TIME
+    // -- LOCAL TIME
 
     public LocalTime toJoda(final java.time.LocalTime input) {
         return new LocalTime(
@@ -57,7 +57,7 @@ public final class JodatimeConverters {
                 millisToNanos(input.getMillisOfSecond()));
     }
 
-    // LOCAL DATE
+    // -- LOCAL DATE
 
     public LocalDate toJoda(final java.time.LocalDate input) {
         return new LocalDate(
@@ -69,7 +69,7 @@ public final class JodatimeConverters {
                 input.getYear(), input.getMonthOfYear(), input.getDayOfMonth());
     }
 
-    // LOCAL DATE TIME
+    // -- LOCAL DATE TIME
 
     public LocalDateTime toJoda(final java.time.LocalDateTime input) {
         return new LocalDateTime(
@@ -85,7 +85,7 @@ public final class JodatimeConverters {
                 millisToNanos(input.getMillisOfSecond()));
     }
 
-    // DATE TIME WITH TIME ZONE DATA
+    // -- DATE TIME WITH TIME ZONE DATA
 
     public DateTime toJoda(final java.time.ZonedDateTime input) {
         return new DateTime(
@@ -103,7 +103,7 @@ public final class JodatimeConverters {
                 fromJoda(input.getZone()));
     }
 
-    // TIME ZONE
+    // -- TIME ZONE
 
     public DateTimeZone toJoda(final java.time.ZoneId input) {
         return DateTimeZone.forID(input.getId());