DateUtils

Utilities for working with dates.
Source:

Methods

(static) combineDateAndTime(date, time) → {Moment}

Combines a date moment with a time moment to return one moment instance.
Source:
Parameters:
Name Type Description
date Moment The date as a moment instance.
time Moment The time as a moment instance.
Returns:
- The combined moment instance.
Type
Moment
DateUtils.combineDateAndTime(moment(), moment().add(7, 'hours').add(23, 'minutes'));

(static) convertToDesktop(date, formatopt) → {String}

Converts a mobile input date to a string using the specified format.
Source:
Parameters:
Name Type Attributes Default Description
date String The input value in the format YYYY-MM-DD.
format String <optional>
'MM/DD/YYYY' The output format.
Returns:
- The formatted date.
Type
String
DateUtils.convertToDesktop('1983-01-19');

(static) convertToMobile(date) → {String}

Converts a desktop input date to the native mobile date format.
Source:
Parameters:
Name Type Description
date String The input value in the format MM/DD/YYYY.
Returns:
- The mobile formatted date.
Type
String
DateUtils.convertToMobile('01/19/1983');

(static) getAsDate(date) → {Date}

Converts a string date from a text or date input to a date object.
Source:
Parameters:
Name Type Description
date String The date in the format MM/DD/YYYY (text input) or YYYY-MM-DD (date input).
Returns:
- The date object.
Type
Date
DateUtils.getAsDate('1983-01-19');
DateUtils.getAsDate('01/19/1983');

(static) getAsMoment(date) → {Moment}

Converts a string date from a text or date input to a moment instance.
Source:
Parameters:
Name Type Description
date String The date in the format MM/DD/YYYY (text input) or YYYY-MM-DD (date input).
Returns:
- The moment instance.
Type
Moment
DateUtils.getAsMoment('1983-01-19');
DateUtils.getAsMoment('01/19/1983');

(static) getHumanDateTimesAsStrings(data) → {Object}

Returns human readable start and end datetime strings from moment objects.
Source:
Parameters:
Name Type Description
data Object The data to pass to the function.
Properties
Name Type Description
startDateTimeObj Moment The date as a moment instance.
endDateTimeObj Moment The time as a moment instance.
isMonthly Boolean Is startDateTimeObj a monthly datetime?
Returns:
- Human readable strings returned for start and end
Type
Object
DateUtils.getHumanDateTimesAsStrings({
    startDateTimeObj: moment(),
    endDateTimeObj: moment().add(7, 'hours').add(23, 'minutes')
});

(static) isAfter(dateToCheck, dateToCompare, useTimeopt) → {Boolean}

Checks if one date is after another.
Source:
Parameters:
Name Type Attributes Default Description
dateToCheck Date The date to check.
dateToCompare Date The date to check against.
useTime Boolean <optional>
false Whether to use the time in the comparison.
Returns:
- Whether the provided date is after the one being checked against.
Type
Boolean
DateUtils.isAfter(new Date(2016, 1, 19), new Date(2016, 3, 14));

(static) isBefore(dateToCheck, dateToCompare, useTimeopt) → {Boolean}

Checks if one date is before another.
Source:
Parameters:
Name Type Attributes Default Description
dateToCheck Date The date to check.
dateToCompare Date The date to check against.
useTime Boolean <optional>
false Whether to use the time in the comparison.
Returns:
- Whether the provided date is before the one being checked against.
Type
Boolean
DateUtils.isBefore(new Date(2016, 1, 19), new Date(2016, 3, 14));

(static) supportsDateInput() → {Boolean}

Check whether input type of 'date' is supported in the current browser.
Source:
Returns:
- Whether the input type is supported.
Type
Boolean
DateUtils.supportsDateInput();