Completely overhaul the API. t-a-i now exports a constructor TaiConverter and a collection of four MODELS, one of which is passed to the constructor to specify in advance the relationship between TAI and Unix time and hence the behaviour of all conversions. The constructor then only has two methods, unixToAtomic and atomicToUnix. Special options can be passed to unixToAtomic in some cases, to retrieve full arrays or closed ranges of TAI millisecond counts in cases where the relationship is one-to-many.
In order to get the arithmetic correct for the new SMEAR model, I added a very rudimentary class Rat expressing a ratio between two BigInts, and another new class Segment which expresses a bounded segment with an origin point and slope, expressed using Rats. Segment can do precise bounds checking and conversions even in asinine situations like smearing out the removal of 0.05 TAI seconds from Unix time. Finally, I upgraded munge to factor in the choice of model before constructing the collection of Segments to pass to the converter - which is largely model-agnostic in its behaviour (well, not really).
The STALL model was a lot of fun because it involves a perfectly horizontal Segment with slope 0 and a bunch of special cases.
Completely overhaul the API.
t-a-i
now exports a constructorTaiConverter
and a collection of fourMODELS
, one of which is passed to the constructor to specify in advance the relationship between TAI and Unix time and hence the behaviour of all conversions. The constructor then only has two methods,unixToAtomic
andatomicToUnix
. Special options can be passed tounixToAtomic
in some cases, to retrieve full arrays or closed ranges of TAI millisecond counts in cases where the relationship is one-to-many.In order to get the arithmetic correct for the new
SMEAR
model, I added a very rudimentary classRat
expressing a ratio between two BigInts, and another new classSegment
which expresses a bounded segment with an origin point and slope, expressed usingRat
s.Segment
can do precise bounds checking and conversions even in asinine situations like smearing out the removal of 0.05 TAI seconds from Unix time. Finally, I upgradedmunge
to factor in the choice of model before constructing the collection ofSegment
s to pass to the converter - which is largely model-agnostic in its behaviour (well, not really).The
STALL
model was a lot of fun because it involves a perfectly horizontalSegment
with slope 0 and a bunch of special cases.Fixes #15.