There is a possible overflow when computing a Double value for fractionalSeconds from an ArraySlice of bytes. Hence, access to this original ArraySlice is necessary.
Modifications:
Add rawFractionalSeconds property to GeneralizedTime.
Add a new public init to GeneralizedTime that accepts rawFractionalSeconds instead of fractionalSeconds and generates the latter from the former.
Adjust the algorithm for computing fractionalSeconds, from a mathematical to a String computation. This is due to the precision mismatch between the mathematical computation and the native Double computation. This issue, which previously did not surface, now does, due to the newly included round-trip conversion from fractionalSeconds to rawFractionalSeconds.
Document that _fractionalSeconds is a cached value and _rawFractionalSeconds is the source of truth for the numerical fractional seconds. (This holds directly for the new GeneralizedTimeinit that takes rawFractionalSeconds. And it holds indirectly for the existing init that takes fractionalSeconds, as no information is lost in the conversion from _fractionalSeconds to _rawFractionalSeconds.)
Result:
The rawFractionalSeconds property now provides the original ArraySlice from which fractionalSeconds was computed.
GeneralizedTime can now compute fractionalSeconds from the provided rawFractionalSeconds.
Motivation:
There is a possible overflow when computing a
Double
value forfractionalSeconds
from anArraySlice
of bytes. Hence, access to this originalArraySlice
is necessary.Modifications:
rawFractionalSeconds
property toGeneralizedTime
.public init
toGeneralizedTime
that acceptsrawFractionalSeconds
instead offractionalSeconds
and generates the latter from the former.fractionalSeconds
, from a mathematical to aString
computation. This is due to the precision mismatch between the mathematical computation and the nativeDouble
computation. This issue, which previously did not surface, now does, due to the newly included round-trip conversion fromfractionalSeconds
torawFractionalSeconds
._fractionalSeconds
is a cached value and_rawFractionalSeconds
is the source of truth for the numerical fractional seconds. (This holds directly for the newGeneralizedTime
init
that takesrawFractionalSeconds
. And it holds indirectly for the existinginit
that takesfractionalSeconds
, as no information is lost in the conversion from_fractionalSeconds
to_rawFractionalSeconds
.)Result:
rawFractionalSeconds
property now provides the originalArraySlice
from whichfractionalSeconds
was computed.GeneralizedTime
can now computefractionalSeconds
from the providedrawFractionalSeconds
.