JuliaLang/julia — pull request #9217 by stevengj (2014-12-01 21:56:29+00:00)
Title: fix #9171: canonicalize CompoundPeriod

As discussed in #9171, this canonicalizes the `CompoundPeriod` type to merge periods of the same type, e.g. `(Dates.Second(2) + Dates.Millisecond(7)) + Dates.Millisecond(1)` now gives `2 seconds, 8 milliseconds`, and to eliminate zero periods. This is needed to make addition of compound periods associative.

It also cleans up a couple of other problems identified in #9171: `CompoundPeriod` is now an `AbstractTime` subtype (like `Period`), addition/subtraction is no longer mutating, missing `+` and `-` methods for two `CompoundPeriod`s were added (as required for associativity), and `==` is no longer object equality.

cc: @quinnj