octal_clock library

Library containing all the Date/Time libraries for handling Octal Time

OctalDateTime is a semi-lazy proxy to dart.core.DateTime that converts the imperial units into octal units.

Due to javascript integer limitations, the two libraries use the millisecond as the common unit for the conversion between time systems. This leads to loss of accuracy due to rounding between the two systems.

Loss of Accuracy

When adding millisecond-level durations to OctalDateTime there can be off-by-one errors due to rounding during the conversion between time systems. The error shouldn't ever be more than +/= 1 millisecond per conversion.

When adding microsecond-level durations to OctalDateTime there is significant loss in accuracy due to the system rounding. Because there are almost two imperial microseconds per octal microsecond, and we do the conversion twice, the error is +/- 4 microseconds.

Classes

OctalDateTime
A class representing an DateTime in Octal format
OctalDuration
A class representing a duration in octal format

Constants

MICROSECONDS_RATIO → const double
Since milliseconds is our base unit, we need are microsecond ratio so that we can properly convert.
MILLISECONDS_RATIO → const double
The smallest unit where the two time systems synchronize is on the hour. We will calculate our conversion ratio using milliseconds as our base unit. This allows this library to work in js and dartvm without too much trouble.

Functions

dec2oct(int decimal) int
Convert a decimal number into its octal representation
oct2dec(int octal) int
Convert an octal number into its decimal representation
toDecimal(int octal, String type, [int? max]) int
Convert an octal value into a decimal value octal the octal value to convert type a string describing this octal value, used for context in error messages max the maximum decimal value allowed