GDTL/DateTimeConcepts-Calculations

BOOST WIKI | GDTL | RecentChanges | Preferences | Page List | Links List

Difference (from prior major revision) (no other diffs)

 A better version of this is delivered with the library: http://www.boost.org/libs/date_time/doc/Calculations.html

A better version of this is delivered with the library: http://www.boost.org/libs/date_time/doc/Calculations.html

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) - 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

```

Here are the "operations" supported by intervals. They are based on half-open range.
``` //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

```

BOOST WIKI | GDTL | RecentChanges | Preferences | Page List | Links List