# Date-Time Concepts - Calculation

Overall Index -- Gregorian Index -- Posix Time Index

Timepoints -- Durations -- Interval -- Special Cases

## Timepoints

This section describes some of basic arithmetic rules that can be performed with timepoints.

     Timepoint + Duration --> Timepoint
     Timepoint - Duration --> Timepoint

     Duration + Timepoint --> Undefined
     Duration - Timepoint --> Undefined

     Timepoint + Timepoint --> Undefined
     Timepoint - Timepoint --> Duration

## Durations

This section describes standard operations for a time duration.

     Duration + Duration  --> Duration
     Duration - Duration  --> Duration

     Duration * Integer   --> Duration
     Integer  * Duration  --> Duration

     Duration(∞) * Integer --> Duration(∞)
     Duration(∞)/Integer   --> Duration(∞)

## Intervals

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 intersects Timeinterval --> bool
     Timeinterval intersection Timeinterval --> Timeperiod //results undefined if no intersection
     Timeinterval contains  Timepoint    --> bool
     Timeinterval contains  Timeinterval --> bool
     Timeinterval shift Duration         --> shift start and end by duration amount

## Special Cases

In general special values such as Not A Date Time (NADT) and infinity should follow rules like floating point values. Note that it should be possible to configure NADT based systems to throw an exception instead of result in NADT.

     Timepoint(NADT) + Duration --> Timepoint(NADT)
     Timepoint(∞) + Duration --> Timepoint(∞)
     Timepoint + Duration(∞) --> Timepoint(∞)
     Timepoint - Duration(∞) --> Timepoint(-∞)