Skip to content

Commit

Permalink
Fix for stefanuebe#136
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanuebe committed Feb 11, 2022
1 parent 264bb4a commit 7815124
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 26 deletions.
4 changes: 2 additions & 2 deletions addon-scheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.vaadin.stefan</groupId>
<artifactId>fullcalendar2-scheduler</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>

<name>FullCalendar Scheduler for Flow</name>
<description>A web component that wraps the FullCalendar Scheduler extension (https://fullcalendar.io).
Expand All @@ -14,7 +14,7 @@
<properties>
<vaadin.version>14.8.3</vaadin.version>

<fullcalendar.version>4.1.0</fullcalendar.version>
<fullcalendar.version>4.1.1</fullcalendar.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion addon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.vaadin.stefan</groupId>
<artifactId>fullcalendar2</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>

<name>FullCalendar for Flow</name>
<description>A web component that wraps the FullCalendar (https://fullcalendar.io).</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import lombok.Getter;
import lombok.ToString;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.*;

/**
* Occurs when the user selects one or multiple timeslots on the calendar. The selected timeslots may contain
Expand All @@ -43,7 +41,16 @@ public class TimeslotsSelectedEvent extends ComponentEvent<FullCalendar> {
*/
private final boolean allDay;

/**
* Returns the start of the event as local date time. Represents the UTC date time this event starts, which
* means the time is the same as when calling {@link #getStartAsInstant()}.
*/
private final LocalDateTime start;

/**
* Returns the end of the event as local date time. Represents the UTC date time this event ends, which
* means the time is the same as when calling {@link #getEndAsInstant()}.
*/
private final LocalDateTime end;

/**
Expand All @@ -64,24 +71,59 @@ public TimeslotsSelectedEvent(FullCalendar source, boolean fromClient, @EventDat
this.end = JsonUtils.parseClientSideDateTime(end);
}

/**
* Returns the entry's start as an {@link Instant}. The contained time is the same as when calling
* {@link #getStart()}.
*
* @return start as Instant
*/
public Instant getStartAsInstant() {
return Timezone.UTC.convertToInstant(start);
}

/**
* Returns the entry's end as an {@link Instant}. The contained time is the same as when calling
* {@link #getEnd()}.
*
* @return end as Instant
*/
public Instant getEndAsInstant() {
return Timezone.UTC.convertToInstant(end);
}

public Instant getStartWithOffset() {
return getSource().getTimezone().convertToInstant(start);
/**
* Returns the start time as a local date time after applying the timezone's offset to
* the utc based start date ({@link #getStart()}). By default the timezone is
* the calendar's timezone or, if no calendar is set yet, UTC.
* <p/>
* @return start with offset
*/
public LocalDateTime getStartWithOffset() {
return getSource().getTimezone().applyTimezoneOffset(start);
}
public Instant getEndWithOffset() {
return getSource().getTimezone().convertToInstant(end);

/**
* Returns the end time as a local date time after applying the timezone's offset to
* the utc based end date ({@link #getEnd()}). By default the timezone is
* the calendar's timezone or, if no calendar is set yet, UTC.
* @return end with offset
*/
public LocalDateTime getEndWithOffset() {
return getSource().getTimezone().applyTimezoneOffset(end);
}

/**
* Returns the start of the event as local date.
* @return start as local date
*/
public LocalDate getStartDate() {
return start.toLocalDate();
}

/**
* Returns the end of the event as local date.
* @return end as local date
*/
public LocalDate getEndDate() {
return end.toLocalDate();
}
Expand Down
6 changes: 3 additions & 3 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.vaadin.stefan</groupId>
<artifactId>fullcalendar-demo</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>

<name>Full Calendar web component demo</name>

Expand All @@ -14,8 +14,8 @@
<properties>
<vaadin.version>14.8.3</vaadin.version>

<fullcalendar.version>4.1.0</fullcalendar.version>
<fullcalendar.scheduler.version>4.1.0</fullcalendar.scheduler.version>
<fullcalendar.version>4.1.1</fullcalendar.version>
<fullcalendar.scheduler.version>4.1.1</fullcalendar.scheduler.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
@CssImport("./app-layout-styles.css")
@SuppressWarnings("rawtypes")
public abstract class AbstractLayout extends AppLayoutRouterLayout implements AfterNavigationObserver {
public static final String ADDON_VERSION = "4.1.0";
public static final String ADDON_VERSION = "4.1.1";
private static final long serialVersionUID = -7479612679602267287L;

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ public AbstractCalendarView() {
* @return initial options
*/
protected JsonObject createDefaultInitialOptions() {
JsonObject initialOptions = Json.createObject();
JsonObject eventTimeFormat = Json.createObject();
//{ hour: 'numeric', minute: '2-digit', timeZoneName: 'short' }
eventTimeFormat.put("hour", "2-digit");
eventTimeFormat.put("minute", "2-digit");
eventTimeFormat.put("timeZoneName", "short");
eventTimeFormat.put("meridiem", false);
eventTimeFormat.put("hour12", false);
initialOptions.put("eventTimeFormat", eventTimeFormat);
JsonObject initialOptions = Json.createObject();
JsonObject eventTimeFormat = Json.createObject();
//{ hour: 'numeric', minute: '2-digit', timeZoneName: 'short' }
eventTimeFormat.put("hour", "2-digit");
eventTimeFormat.put("minute", "2-digit");
eventTimeFormat.put("timeZoneName", "short");
eventTimeFormat.put("meridiem", false);
eventTimeFormat.put("hour12", false);
initialOptions.put("eventTimeFormat", eventTimeFormat);
return initialOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ protected FullCalendar createCalendar(JsonObject defaultInitialOptions) {
// extend the initial options with the necessary client side settings to add the custom view
CUSTOM_VIEW.extendInitialOptions(defaultInitialOptions);

FullCalendar calendar = FullCalendarBuilder.create()
.withInitialOptions(defaultInitialOptions)
FullCalendar calendar = FullCalendarBuilder.create()
.withInitialOptions(defaultInitialOptions)
.withInitialEntries(EntryService.createRandomInstance().getEntries())
.withEntryLimit(3)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -77,6 +78,12 @@ protected FullCalendar createCalendar(JsonObject defaultInitialOptions) {
});

((FullCalendarScheduler) calendar).addTimeslotsSelectedSchedulerListener((event) -> {
System.out.println( "ZoneId: " + event.getSource().getTimezone().getZoneId() );
LocalDateTime startDate = event.getStart();
System.out.println( "getStart(): " + event.getStart() );
System.out.println( "getStartWithOffset(): " + event.getStartWithOffset() );


ResourceEntry entry = new ResourceEntry();

entry.setStart(event.getStart());
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.vaadin.stefan</groupId>
<artifactId>fullcalendar-parent</artifactId>
<version>4.1.0</version>
<version>4.1.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down

0 comments on commit 7815124

Please sign in to comment.