clj-time/clj-time — pull request #157 by wyegelwel (2014-11-21 03:20:33+00:00)
Title: Add in-time-unit support for Periods

Creates protocol InTimeUnitProtocol for in- functions and has both Interval and ReadablePeriod extend that protocol.

When a Month or Year is passed to a standard time unit (millis, seconds, minutes, hours, days, weeks), an UnsupportedOperationException is thrown courtesy of JodaTime.

There is no good support for doing in-months or in-years with JodaTime, so I tried to do something reasonable. Specifically, if the Period is a Month or Year it will return the int, scaling of a month -> year or year -> month using the standard 12 months in a year assumption. If any other PeriodType is passed to those functions, an UnsupportedOperationException is thrown to mirror the behavior of the other functions / JodaTime.

Tests have been added, none of the previous tests changed.