Intervals implementation.

Constructor

inline new (dtic:DateTimeIntervalCore)

Constructor.

Methods

addTo (dt:DateTime):DateTime

Add this interval to specified DateTime instance.

Returns new DateTime.

inline format (format:String):String

Formats the interval

*
*   - `%%` Literal %. Example:   %
*   - `%Y` Years, numeric, at least 2 digits with leading 0. Example:    01, 03
*   - `%y` Years, numeric. Example:  1, 3
*   - `%M` Months, numeric, at least 2 digits with leading 0. Example:   01, 03, 12
*   - `%m` Months, numeric. Example: 1, 3, 12
*   - `%b` Total number of months. Example:   2, 15, 36
*   - `%D` Days, numeric, at least 2 digits with leading 0. Example: 01, 03, 31
*   - `%d` Days, numeric. Example:   1, 3, 31
*   - `%a` Total number of days. Example:   4, 18, 8123
*   - `%H` Hours, numeric, at least 2 digits with leading 0. Example:    01, 03, 23
*   - `%h` Hours, numeric. Example:  1, 3, 23
*   - `%c` Total number of hours. Example:   4, 18, 8123
*   - `%I` Minutes, numeric, at least 2 digits with leading 0. Example:  01, 03, 59
*   - `%i` Minutes, numeric. Example:    1, 3, 59
*   - `%e` Total number of minutes. Example:   4, 18, 8123
*   - `%S` Seconds, numeric, at least 2 digits with leading 0. Example:  01, 03, 57
*   - `%s` Seconds, numeric. Example:    1, 3, 57
*   - `%f` Total number of seconds. Example:   4, 18, 8123
*   - `%R` Sign "-" when negative, "+" when positive. Example:   -, +
*   - `%r` Sign "-" when negative, empty when positive. Example: -,

inline formatPartial (format:Array<String>):Array<String>

Formats each string in format array. Each string can have only one placeholder.

Supported placeholders: see format() method description except r,R,% placeholders.

Returns new array with elements, whose corresponding strings in format array were filled with non-zero values.

Example: if interval contains 0 years, 2 months and 10 days, then interval.format(['%y years', '%m months', '%d days']).join(',') will return '2 months, 10 days'

getDays ():Int

Get amount of full days in this interval (always less then 31)

getHours ():Int

Get amount of full hours in this interval (always less then 24)

getMinutes ():Int

Get amount of full minutes in this interval (always less then 60)

getMonths ():Int

Get amount of full months in this interval (always less then 12)

getSeconds ():Int

Get amount of full seconds in this interval (always less then 60)

getTotalDays ():Int

Get total amount of days in this interval.

getTotalHours ():Int

Get total amount of hours in this interval.

getTotalMinutes ():Int

Get total amount of minutes in this interval.

getTotalMonths ():Int

Get total amount of months in this interval.

E.g. if interval contains 3 years and 5 months, then interval.getTotalMonths() returns 3 * 12 + 5 = 41

getTotalSeconds ():Float

Get total amount of seconds in this interval.

getTotalWeeks ():Int

Get total amount of weeks in this interval.

Not calendar weeks, but each 7 days.

getYears ():Int

Get amount of full years in this interval.

inline invert ():DateTimeInterval

Invert the sign of this interval. Modifies internal state. Returns itself.

inline sign ():Int

Returns -1 if this is a negative interval, +1 otherwise

subFrom (dt:DateTime):DateTime

Substract this interval from specified DateTime instance.

Returns new DateTime.

toString ():String

Get string representation of this interval.

Static methods

staticcreate (begin:DateTime, end:DateTime):DateTimeInterval

Create interval as difference between two DateTime instances