isaacgrant/swat — pull request #2 by isaacgrant (2014-01-29 19:22:01+00:00)
Title: More flexible human formatted date interval code.

Prior to this the SwatString::toHumanReadableTimePeriod() always used the same
set of interval parts, and using a different format required rewriting the
entire method.

SwatString::toHumanReadableTimePeriod() is broken up into three methods:
1. getHumanReadableTimePeriodParts() to generate the array of human readable date parts.
2. toHumanReadableTimePeriodString() to combine that array together, and optional only keep the largest part.
3. toHumanReadableTimePeriod() which uses the above methods to return a basic string.

SwatString::getHumanReadableTimePeriodParts() can accept a format to return by
passing a bitwise and of the new SwatDATE::DI_* contants.

Along side this flexibility, I've added new convenience methods to SwatDate and
SwatString.

"withWeeks" methods that use weeks instead of months:
* SwatDate::getHumanReadableDateDiffWithWeeks()
* SwatString::toHumanReadableTimePeriodWithWeeks()

"withWeeksAndDays" methods always return the largest part of the time
difference, and treat weeks and days as a single part:
* SwatDate::getHumanReadableDateDiffWithWeeksAndDays()
* SwatString::toHumanReadableTimePeriodWithWeeksAndDays()