Declared in NSCalendar+DateAlignment.h
NSCalendar+DateAlignment.mm

Overview

Calendar methods for aligning dates to some particular units. Used for timeline UI widget implementation.

Instance Methods

alignDateRangeFromDate:toDate:resolution:

Aligns the time range. The new range contains a specified one completely.

- (void)alignDateRangeFromDate:(inout NSDate **)fromDate_ toDate:(inout NSDate **)toDate_ resolution:(ESDateResolution)resolution_

Parameters

fromDate_

The beginning of the range to align. Aligned to past.

toDate_

Theend of the range to align. Aligned to future.

resolution_

Resolution to align dates against

Discussion

Warning : Unsafe function. The parameters are in-out. Does in-place replacement. Note : does not accept NULL parameters and invalid time ranges.

Declared In

NSCalendar+DateAlignment.h

alignToFutureDate:resolution:

Aligns date to the beginning of the next unit.

- (NSDate *)alignToFutureDate:(NSDate *)date_ resolution:(ESDateResolution)resolution_

Parameters

date_

A date to align

resolution_

Resolution to align dates against

Return Value

Aligned date.

Discussion

For example Month : ‘2013-12-03’ –> ‘2014-01-01’

Declared In

NSCalendar+DateAlignment.h

alignToPastDate:resolution:

Aligns date to the beginning of the current unit.

- (NSDate *)alignToPastDate:(NSDate *)date_ resolution:(ESDateResolution)resolution_

Parameters

date_

A date to align

resolution_

Resolution to align dates against

Return Value

Aligned date.

Discussion

For example Month : ‘2013-12-03’ –> ‘2013-12-01’

Declared In

NSCalendar+DateAlignment.h

dateByAddingTimeIntervals:toDate:resolution:

Adds some units to a given date.

- (NSDate *)dateByAddingTimeIntervals:(NSInteger)intervals_ toDate:(NSDate *)date_ resolution:(ESDateResolution)resolution_

Parameters

intervals_

Count of the intervals to add. Subtracts the intervals if a negative number is passed.

date_

A base date for computations.

resolution_

Unit to add or subtract

Return Value

A date with added units.

Discussion

result = date + intervals * resolution_

Declared In

NSCalendar+DateAlignment.h

maximumResolutionFromDate:toDate:

Calculates a maximal time interval that can fit into the dates range completely.

- (ESDateResolution)maximumResolutionFromDate:(NSDate *)fromDate_ toDate:(NSDate *)toDate_

Parameters

fromDate_

The beginning of a time range.

toDate_

The end of a time range.

Return Value

A unit for the maximal time interval.

Discussion

result = max( ESDateResolution ) : resolution <= ( toDate - fromDate )

Declared In

NSCalendar+DateAlignment.h