Package types.collections.time
Class datespanset
- All Implemented Interfaces:
Base
,Collection
,Time
,TimeCollection
,TemporalObject
Class for representing lists of disjoint tstzspans.
:class:``DateSpanSet`` objects can be created with a single argument of type string as in MobilityDB.
>>> DateSpanSet(string='{[2019-09-08, 2019-09-10], [2019-09-11, 2019-09-12]}')
Another possibility is to give a list specifying the composing
tstzspans, which can be instances of :class:``str`` or :class:``DateSpan``.
The composing datespans must be given in increasing order.
>>> DateSpanSet(span_list=['[2019-09-08, 2019-09-10]', '[2019-09-11, 2019-09-12]'])
>>> DateSpanSet(span_list=[TsTzSpan('[2019-09-08, 2019-09-10]'), TsTzSpan('[2019-09-11, 2019-09-12]')])
- Author:
- ARIJIT SAMAL
-
Field Summary
-
Constructor Summary
ConstructorDescriptiondatespanset
(String str) datespanset
(List<?> dspan) datespanset
(jnr.ffi.Pointer inner) -
Method Summary
Modifier and TypeMethodDescriptionboolean
jnr.ffi.Pointer
createInner
(jnr.ffi.Pointer inner) jnr.ffi.Pointer
createStringInner
(String str) date_adt_to_date
(int ts) Function to convert the integer timestamp to LocalDate format so that it can be used by other librariesdate_n
(int n) Returns the n-th date in ``self``.int
dateToTimestamp
(LocalDate date) Returns whether ``self`` temporally contains ``content``.Returns the temporal distance between ``self`` and ``other``.duration
(boolean ignore_gaps) Returns the duration of ``self``.elements()
end_date()
Returns the last date in ``self``.jnr.ffi.Pointer
intersection
(Object other) Returns the temporal intersection of ``self`` and ``other``.boolean
is_adjacent
(Object other) Returns whether ``self`` is adjacent to ``other``.boolean
boolean
boolean
Returns whether ``self`` is strictly before ``other``.boolean
is_over_or_after
(Object other) boolean
is_over_or_before
(Object other) boolean
is_over_or_left
(Object other) Returns whether ``self`` is before ``other`` allowing overlap.boolean
is_over_or_right
(Object other) Returns whether ``self`` is after ``other`` allowing overlap.boolean
Returns whether ``self`` is strictly after ``other``.Returns the temporal difference of ``self`` and ``other``.int
boolean
Returns whether ``self`` temporally overlaps ``other``.scale
(int duration) Returns a new :class:`DateSpan` that starts as ``self`` but has duration ``duration``.shift
(int shift) Returns a new :class:`DateSpan` that is the result of shifting ``self`` by ``delta``.shift_scale
(Integer shift, Integer duration) Returns a new :class:`DateSpan` that starts at ``self`` shifted by ``shift`` and has duration ``duration`` Examples: >>> DateSpan('[2000-01-01, 2000-01-10]').shift_scale(shift=timedelta(days=2), duration=timedelta(days=4)) >>> 'DateSpan([2000-01-03, 2000-01-07])' Args: shift: :class:`datetime.timedelta` instance to shift duration: :class:`datetime.timedelta` instance representing the duration of the new dateSpan Returns: A new :class:`DateSpan` instance MEOS Functions: datespan_shift_scalespan_n
(int n) Returns the first date in ``self``.subtract_from
(Object other) static LocalDate
timestampToLocalDate
(int timestamp) convert timestamp (number of seconds since epoch) to LocalDatestatic LocalDateTime
timestampToLocalDateTime
(int timestamp) Convert timestamp (number of seconds since epoch) to LocalDateTimeto_span()
Returns a :class:`DateSpanSet` set containing ``self``.Returns a :class:`TsTzSpan equivalent to ``self``.toString()
Returns the temporal union of ``self`` and ``other``.Methods inherited from class types.collections.base.SpanSet
add, as_hexwkb, as_wkb, contains, copy, end_span, eq, from_hexwkb, from_wkb, greaterThan, greaterThanOrEqual, hash, intersection, is_adjacent, is_contained_in, is_left, is_over_or_left, is_over_or_right, is_right, is_same, lessThan, lessThanOrEqual, minus, mul, notEquals, num_spans, overlaps, span_n, spans, start_span, sub, to_span, union
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface types.collections.base.Collection
contains, is_contained_in, is_left, is_over_or_left, is_over_or_right, is_right, overlaps
-
Field Details
-
_inner
private final jnr.ffi.Pointer _inner
-
-
Constructor Details
-
datespanset
public datespanset(jnr.ffi.Pointer inner) -
datespanset
-
datespanset
-
-
Method Details
-
to_span
public datespan to_span() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessExceptionReturns a :class:`DateSpanSet` set containing ``self``. Returns: A new :class:`DateSpanSet` instance MEOS Functions: span_to_spanset -
to_tstzspanset
public tstzspanset to_tstzspanset() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessExceptionReturns a :class:`TsTzSpan equivalent to ``self``. Returns: A new :class:`TsTzSpan` instance MEOS Functions: datespan_to_tstzspan -
duration
public Duration duration(boolean ignore_gaps) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException Returns the duration of ``self``. Returns: A :class:`datetime.timedelta` instance representing the duration of the :class:`DateSpan` MEOS Functions: datespan_duration -
num_dates
public int num_dates() -
createInner
public jnr.ffi.Pointer createInner(jnr.ffi.Pointer inner) - Specified by:
createInner
in classSpanSet<LocalDate>
-
createStringInner
- Specified by:
createStringInner
in classSpanSet<LocalDate>
-
get_inner
public jnr.ffi.Pointer get_inner() -
start_date
-
end_date
-
date_n
Returns the n-th date in ``self``. Returns: A :class:`date` instance MEOS Functions:- Throws:
Exception
-
toString
-
date_adt_to_date
Function to convert the integer timestamp to LocalDate format so that it can be used by other libraries -
start_span
Returns the first date in ``self``. Returns: A :class:`date` instance MEOS Functions: dateset_start_value- Throws:
org.locationtech.jts.io.ParseException
-
end_element
Returns the last date in ``self``. Returns: A :class:`date` instance MEOS Functions: dateset_end_value- Throws:
org.locationtech.jts.io.ParseException
-
span_n
- Throws:
org.locationtech.jts.io.ParseException
-
elements
- Throws:
Exception
-
scale
Returns a new :class:`DateSpan` that starts as ``self`` but has duration ``duration``. Examples: >>> DateSpan('[2000-01-01, 2000-01-10]').scale(timedelta(days=2)) >>> 'DateSpan([2000-01-01, 2000-01-03])' Args: duration: :class:`datetime.timedelta` instance representing the duration of the new dateSpan Returns: A new :class:`DateSpan` instance MEOS Functions: datespan_shift_scale -
shift
Returns a new :class:`DateSpan` that is the result of shifting ``self`` by ``delta``. Examples: >>> DateSpan('[2000-01-01, 2000-01-10]').shift(timedelta(days=2)) >>> 'DateSpan([2000-01-03, 2000-01-12])' Args: delta: :class:`datetime.timedelta` instance to shift Returns: A new :class:`DateSpan` instance MEOS Functions: datespan_shift_scale -
shift_scale
Returns a new :class:`DateSpan` that starts at ``self`` shifted by ``shift`` and has duration ``duration`` Examples: >>> DateSpan('[2000-01-01, 2000-01-10]').shift_scale(shift=timedelta(days=2), duration=timedelta(days=4)) >>> 'DateSpan([2000-01-03, 2000-01-07])' Args: shift: :class:`datetime.timedelta` instance to shift duration: :class:`datetime.timedelta` instance representing the duration of the new dateSpan Returns: A new :class:`DateSpan` instance MEOS Functions: datespan_shift_scale -
dateToTimestamp
Returns whether ``self`` temporally contains ``content``. Examples: >>> DateSpan('[2012-01-01, 2012-01-04]').contains(DateSpan('[2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-01, 2012-01-02]').contains(DateSpan('(2012-01-01, 2012-01-02)')) >>> True >>> DateSpan('(2012-01-01, 2012-01-02)').contains(DateSpan('[2012-01-01, 2012-01-02]')) >>> False Args: content: temporal object to compare with Returns: True if contains, False otherwise MEOS Functions: contains_span_span, contains_span_spanset, contains_span_date -
contains
- Throws:
Exception
-
is_adjacent
Returns whether ``self`` is adjacent to ``other``. That is, they share a bound but only one of them contains it. Args: other: object to compare with Returns: True if adjacent, False otherwise MEOS Functions: adjacent_span_span, adjacent_span_spanset, adjacent_span_date- Throws:
Exception
-
overlaps
Returns whether ``self`` temporally overlaps ``other``. That is, both share at least an instant Examples: >>> DateSpan('[2012-01-01, 2012-01-02]').overlaps(DateSpan('[2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-01, 2012-01-02)').overlaps(DateSpan('[2012-01-02, 2012-01-03]')) >>> False >>> DateSpan('[2012-01-01, 2012-01-02)').overlaps(DateSpan('(2012-01-02, 2012-01-03]')) >>> False Args: other: temporal object to compare with Returns: True if overlaps, False otherwise MEOS Functions: overlaps_span_span, overlaps_span_spanset- Throws:
Exception
-
is_left
Returns whether ``self`` is strictly before ``other``. That is, ``self`` ends before ``other`` starts. Examples: >>> DateSpan('[2012-01-01, 2012-01-02)').is_left(DateSpan('[2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-01, 2012-01-02)').is_left(DateSpan('(2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-01, 2012-01-02]').is_left(DateSpan('[2012-01-02, 2012-01-03]')) >>> False Args: other: temporal object to compare with Returns: True if before, False otherwise MEOS Functions: left_span_span, left_span_spanset, before_span_date,- Throws:
Exception
-
is_over_or_left
Returns whether ``self`` is before ``other`` allowing overlap. That is, ``self`` ends before ``other`` ends (or at the same time). Examples: >>> DateSpan('[2012-01-01, 2012-01-02)').is_over_or_left(DateSpan('[2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-01, 2012-01-02]').is_over_or_left(DateSpan('[2012-01-02, 2012-01-03]')) >>> True >>> DateSpan('[2012-01-03, 2012-01-05]').is_over_or_left(DateSpan('[2012-01-01, 2012-01-04]')) >>> False Args: other: temporal object to compare with Returns: True if before, False otherwise MEOS Functions: overleft_span_span, overleft_span_spanset, overbefore_span_date,- Throws:
Exception
-
is_over_or_right
Returns whether ``self`` is after ``other`` allowing overlap. That is, ``self`` starts after ``other`` starts (or at the same time). Examples: >>> DateSet('{2012-01-02, 2012-01-03}').is_over_or_right(DateSpan('[2012-01-01, 2012-01-02)')) >>> True >>> DateSet('{2012-01-02, 2012-01-03}').is_over_or_right(DateSpan('[2012-01-01, 2012-01-02]')) >>> True >>> DateSet('{2012-01-02, 2012-01-03}').is_over_or_right(DateSpan('[2012-01-01, 2012-01-03]')) >>> False Args: other: temporal object to compare with Returns: True if overlapping or after, False otherwise MEOS Functions: overafter_set_date, overright_span_span, overright_span_spanset- Throws:
Exception
-
is_right
Returns whether ``self`` is strictly after ``other``. That is, ``self`` starts after ``other`` ends. Examples: >>> DateSpan('[2012-01-02, 2012-01-03]').is_right(DateSpan('[2012-01-01, 2012-01-02)')) >>> True >>> DateSpan('(2012-01-02, 2012-01-03]').is_right(DateSpan('[2012-01-01, 2012-01-02)')) >>> True >>> DateSpan('[2012-01-02, 2012-01-03]').is_right(DateSpan('[2012-01-01, 2012-01-02]')) >>> False Args: other: temporal object to compare with Returns: True if after, False otherwise MEOS Functions: right_span_span, right_span_spanset, after_span_date,- Throws:
Exception
-
is_before
- Specified by:
is_before
in interfaceTimeCollection
- Throws:
Exception
-
is_over_or_before
- Specified by:
is_over_or_before
in interfaceTimeCollection
- Throws:
Exception
-
is_over_or_after
- Specified by:
is_over_or_after
in interfaceTimeCollection
- Throws:
Exception
-
is_after
- Specified by:
is_after
in interfaceTimeCollection
- Throws:
Exception
-
distance
Returns the temporal distance between ``self`` and ``other``. Args: other: temporal object to compare with Returns: A :class:`datetime.timedelta` instance MEOS Functions: distance_set_date, distance_dateset_dateset, distance_datespanset_datespan, distance_datespanset_datespanset- Throws:
Exception
-
timestampToLocalDateTime
Convert timestamp (number of seconds since epoch) to LocalDateTime -
intersection
Returns the temporal intersection of ``self`` and ``other``. Args: other: temporal object to intersect with Returns: A :class:`TimeDate` instance. The actual class depends on ``other``. MEOS Functions: intersection_set_date, intersection_set_set, intersection_spanset_span, intersection_spanset_spanset- Throws:
Exception
-
minus
Returns the temporal difference of ``self`` and ``other``. Args: other: temporal object to diff with Returns: A :class:`DateSpanSet` instance. MEOS Functions: minus_span_date, minus_span_spanset, minus_span_span- Throws:
Exception
-
timestampToLocalDate
convert timestamp (number of seconds since epoch) to LocalDate -
subtract_from
- Throws:
Exception
-
union
Returns the temporal union of ``self`` and ``other``. Args: other: temporal object to merge with Returns: A :class:`DateSpanSet` instance. MEOS Functions: union_span_date, union_spanset_span, union_span_span- Throws:
Exception
-