Utilities for working with times.
- Source:
Methods
(static) getAsDate(time) → {Date}
Converts a time to a date object.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
time |
String | The input value in the format hh:mm A. |
Returns:
- The time inside of a date object.
- Type
- Date
TimeUtils.getAsDate('10:19 PM');
(static) getAsMoment(time) → {Moment}
Converts a time to a moment instance.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
time |
String | The input value in the format hh:mm A. |
Returns:
- The time inside of a moment instance.
- Type
- Moment
TimeUtils.getAsMoment('10:19 PM');
(static) getFromValuesAsString(hours, minutes, roundMinutesDownopt, stepopt) → {String}
Provides the formatted time from hours and minutes values.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
hours |
Number | The hours in a 24 hour format. | ||
minutes |
Number | The minutes from 0 - 60. | ||
roundMinutesDown |
Boolean |
<optional> |
false | Whether to round the minutes down to the provided step. |
step |
Number |
<optional> |
1 | The step to round minutes down to. |
Returns:
- The formatted time.
- Type
- String
TimeUtils.getFromValuesAsString(20, 35); // '08:35 PM'
(static) getMobileAsString(time, stepopt) → {String}
Converts a mobile input time to a string in the format hh:mm A.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
time |
String | The input value in the format HH:mm (24 hour format). | ||
step |
Number |
<optional> |
1 | The step to round down to. |
Returns:
- The formatted time.
- Type
- String
TimeUtils.getMobileAsString('22:19'); // 10:19 PM
(static) getTimes(data) → {Array}
Generate an array of times.
- Source:
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | The data to pass to the function.
Properties
|
Returns:
times - An array of times.
- Type
- Array
TimeUtils.getTimes({
step: 30,
format: 'hh:mm A'
});
(static) getValuesFromString(time, stepopt) → {Object}
Provides the hours, minutes, and meridiem from a time string.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
time |
String | The input value in the format hh:mm A. | ||
step |
Number |
<optional> |
1 | The step to round down to. |
Returns:
- The object containing the hours, minutes, and meridiem.
- Type
- Object
TimeUtils.getValuesFromString('10:19 AM');
(static) normalizeToStep(time, stepopt) → {String}
Normalizes the provided time down to the provided step.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
time |
String | The input value in the format hh:mm A. | ||
step |
Number |
<optional> |
1 | The step to round down to. |
Returns:
- The normalized time.
- Type
- String
TimeUtils.normalizeToStep('07:07 PM', 15); // '07:00 PM'