What kind of mathematical/algebraic structure is DateTime + TimeSpan?

82 Views Asked by At

Consider a DateTime to be a specified absolute 'point in time' (represented with respect to some fixed convention, for example milliseconds since midnight on the first Taungsday of the first month of the year 42 ABY).

Consider a TimeSpan to be a distance between two DateTimes, for example some aggregate representation of millisecond distance.

Clearly, all the TimeSpans (under the same convention) form a vector space over the real numbers.

DateTime instances, on the other hand, have the following operations

++ : DateTime -> TimeSpan -> DateTime
-- : DateTime -> DateTime -> TimeSpan

satisfying, for all dt0, dt1 : DateTime and for all ts0, ts1 : TimeSpan

dt0 ++ (dt1 -- dt0) = dt1
(dt0 ++ ts0) ++ ts1 = dt0 ++ (ts0 + ts1)

and that's it, I think.

In one sense, a DateTime is 'just' a TimeSpan 'applied to' a particular origin point (which collapses the distinction between DateTime and TimeSpan), but this structure can clearly exist without any defined origin, so that is unsatisfactory.

This DateTime/TimeSpan structure strikes me as isomorphic to any one-dimensional infinite vector space augmented with a notion of absolute position. Note that this does not require there to be a defined origin. E.g. 1-D cartesian space, or a similar DateTime/TimeSpan space but with different origin and scaling.

Is there a name for objects like this?

1

There are 1 best solutions below

1
On BEST ANSWER

An affine space. The difference between two points in an affine space is a vector, and a vector can be added to a point in an affine space to get another point in the affine space.