mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-27 09:01:38 +01:00
Fixed number of days for all-day events
All events were forced to last 1 day, now longer events have their actual durations
This commit is contained in:
parent
c24ef44055
commit
c2783ae82e
@ -33,6 +33,7 @@ import java.util.List;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
import de.greenrobot.dao.query.QueryBuilder;
|
import de.greenrobot.dao.query.QueryBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
@ -194,11 +195,13 @@ public class CalendarReceiver extends BroadcastReceiver {
|
|||||||
//force the all day events to begin at midnight and last a whole day
|
//force the all day events to begin at midnight and last a whole day
|
||||||
OffsetDateTime o = OffsetDateTime.now();
|
OffsetDateTime o = OffsetDateTime.now();
|
||||||
LocalDateTime d = LocalDateTime.ofEpochSecond(calendarEvent.getBegin()/1000, 0, o.getOffset());
|
LocalDateTime d = LocalDateTime.ofEpochSecond(calendarEvent.getBegin()/1000, 0, o.getOffset());
|
||||||
|
LocalDateTime fin = LocalDateTime.ofEpochSecond(calendarEvent.getEnd()/1000, 0, o.getOffset());
|
||||||
|
int numDays = (int)ChronoUnit.DAYS.between(d, fin);
|
||||||
o = OffsetDateTime.of(d, o.getOffset()).withHour(0);
|
o = OffsetDateTime.of(d, o.getOffset()).withHour(0);
|
||||||
//workaround for negative timezones
|
//workaround for negative timezones
|
||||||
if(o.getOffset().compareTo(ZoneOffset.UTC)>0) o = o.plusDays(1);
|
if(o.getOffset().compareTo(ZoneOffset.UTC)>0) o = o.plusDays(1);
|
||||||
calendarEventSpec.timestamp = (int)o.toEpochSecond();
|
calendarEventSpec.timestamp = (int)o.toEpochSecond();
|
||||||
calendarEventSpec.durationInSeconds = 24 * 60 * 60;
|
calendarEventSpec.durationInSeconds = 24 * 60 * 60 * numDays;
|
||||||
}
|
}
|
||||||
calendarEventSpec.description = calendarEvent.getDescription();
|
calendarEventSpec.description = calendarEvent.getDescription();
|
||||||
calendarEventSpec.location = calendarEvent.getLocation();
|
calendarEventSpec.location = calendarEvent.getLocation();
|
||||||
|
Loading…
Reference in New Issue
Block a user