`DateTime` arithmetic on `Microsecond` (or smaller) scale

I personally don’t need any finer precision than milliseconds when operating with DateTimes but I don’t like that various operations with Micro- and Nanoseconds are available without throwing a warning. Its feels like wrong advertising. If Julia allows to add periods to dates the result is expected to be accurate or the operation should error.
Imagine operations on Strings silently taking away a couple of chars because of limitations in the internal implementation. There would be no discussion that this isn’t the right behaviour.

It is also not coherent to allow operations with hidden truncating given that:

  • Addition of Milliseconds and Nanoseconds result in a CompoundPeriod without losing accuracy:
julia> Millisecond(1)  + Nanosecond(1)
1 millisecond, 1 nanosecond
  • Operations on periods alone do throw InexactError:
julia> Millisecond(1)  / 2
ERROR: InexactError: Int64(0.5)
3 Likes