A better version of this is delivered with the library:|
This section describes some of basic arithmetic rules that can be performed with GDTL components.
Timepoint + Timepoint --> Undefined Timepoint - Timepoint --> Duration Timepoint + Duration --> Timepoint Timepoint - Duration --> Timepoint Duration + Timepoint --> Undefined (possible, but for symmetry with subtraction?) Duration - Timepoint --> Undefined Duration + Duration --> Duration Duration - Duration --> Duration Duration * Integer --> Duration //These thanks to suggestion by Ian Mitchell Integer * Duration --> Duration Duration/Integer --> Duration //via integer division rules, so do we need mod too? Duration(∞) * Integer --> Duration(∞) Duration(∞)/Integer --> Duration(∞)
In general special values such as Not A Date Time (NADT), Not A Time Interval (NATI) and infinity should follow rules like floating point values. Note that it should be possible to configure NADT/NATI based systems to throw an exception instead of result in NADT/NATI.
Timepoint(∞) + Duration --> Timepoint(∞) Timepoint + Duration(∞) --> Timepoint(∞) Timepoint - Duration(∞) --> Timepoint(-∞) Timepoint(NADT) + Duration --> Timepoint(NADT) or exception Timepoint(NADT) - Timepoint --> Duration(NATI) or exception Timepoint - Timepoint(NATI) --> Duration(NATI) or exception Duration(NATI) + Duration --> Duration(NATI) or exception Duration(NATI) - Duration --> Duration(NATI) or exception Duration(NATI) * Integer --> Duration(NATI) or exception
//These can be defined by either of 2 Timepoints or a Timepoint and Duration Timeinterval contains Timepoint --> bool Timeinterval contains Timeinterval --> bool Timeinterval intersects Timeinterval --> bool Timeinterval intersection Timeinterval --> Timeinterval //results undefined or Timeinterval(NATI) if no intersection Timeinterval shift Duration --> shift start and end by duration amount