mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
Merge branch 'timerange' into gpsfixstore-independent-of-race
This commit is contained in:
commit
c1c60dbeb2
2 files changed
+16
No files matched your search
@@ -34,4 +34,13 @@ public interface TimeRange extends Comparable<TimeRange>, Serializable {
|
||||
boolean startsBefore(TimeRange other);
|
||||
|
||||
boolean endsAfter(TimeRange other);
|
||||
|
||||
/**
|
||||
* Get time-difference between the timepoint and this timerange.
|
||||
* It will be 0 if the timepoint lies within the timerange, otherwise the time-difference
|
||||
* to either the start or end of the timerange, depending on which is closer
|
||||
* @param timePoint
|
||||
* @return
|
||||
*/
|
||||
long timeDifference(TimePoint timePoint);
|
||||
}
|
||||
+7
@@ -57,4 +57,11 @@ public class TimeRangeImpl extends Pair<TimePoint, TimePoint> implements TimeRan
|
||||
public boolean endsAfter(TimeRange other) {
|
||||
return to().after(other.to());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long timeDifference(TimePoint timePoint) {
|
||||
if (includes(timePoint)) return 0;
|
||||
if (timePoint.before(from())) return from().asMillis() - timePoint.asMillis();
|
||||
return to().asMillis() - timePoint.asMillis();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user