Building the library with open sourcing in mind from the beginning meant that I didn’t let myself take any shortcuts, which means that the result is rock-solid (and has good test coverage at least for the data structures). I’m pretty sure that the end result is much much better due to this approach 🙂
In addition, I decided to write the library purely in Swift, while maintaining at least some level of Objective-C backwards compatibility (as Timing is still written in Objective-C).
The library’s main data structure is a DateRange enum which lets you specify:
- A custom date range
- The past N days
- A calendar unit (e.g. day, week, month, quarter, year), with a specific offset from the current date. E.g. (0, month) corresponds to this month while (-1, quarter) represents last quarter.
As an enum, this structure unfortunately is not available from Objective-C, but the control itself provides e.g. KVO-observable start and end date properties for backwards compatibility. In addition, the control follows the target-action pattern. You can also serialize the currently selected date range to and from an NSData object in order to persist it between launches of your app.
If this sounds useful or interesting to you, please have a look at the project on GitHub. Feedback and pull requests are more than welcome!