Constructor
new TimeUtils()
- Source:
Methods
(static) addHours(time, hoursToAdd) → {number}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
time |
|
HHMM |
hoursToAdd |
|
|
Returns:
HHMM
-
Type
-
number
(static) addMinutes(time, minutesToAdd) → {number}
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
time |
|
HHMM |
minutesToAdd |
|
|
Returns:
HHMM
-
Type
-
number
(static) current() → {number}
- Description:
- Returns the current time in HHMM format.
- Source:
Returns:
HHMM
-
Type
-
number
(static) dateToTime(dt) → {number}
- Source:
- Deprecated:
- Convert a Date object into a numeric time HHMM
dropping the date portion.
- See:
-
Parameters:
| Name |
Type |
Description |
dt |
Date
|
|
Returns:
HHMM
-
Type
-
number
(static) diff(t1, t2) → {null|number}
- Description:
- Returns the total minutes between two times.
- Source:
Parameters:
| Name |
Type |
Description |
t1 |
number
|
HHMM |
t2 |
number
|
HHMM |
Returns:
-
Type
-
null
|
number
- Description:
- Source:
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
val |
Date
|
number
|
string
|
|
|
– Date object, HHMM integer, or HHMM string |
zeroFill |
boolean
|
|
false
|
|
tz |
string
|
<optional>
|
|
– IANA zone name (e.g. "America/New_York").
Omit or pass falsy to stay in the host’s local zone. |
Returns:
"hh:mm AM/PM"
-
Type
-
string
- Description:
- Format time with timezone.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
Date
|
|
Returns:
hh:mm XM XST
-
Type
-
string
(static) hours(time) → {number}
- Description:
- Returns the hours portion of a time in an integer representation formatted HHMM
- Source:
Parameters:
| Name |
Type |
Description |
time |
number
|
HHMM |
Returns:
-
Type
-
number
(static) isValid(time) → {boolean}
- Description:
- Is argument a valid numeric or string time?
Note: This function should probably not be called if you are going to follow it up with a call to
strToInt(). The reason is that this function calls that function. You would be calling it twice.
Just call strToInt() and compare it to null.
- Source:
Parameters:
| Name |
Type |
Description |
time |
number
|
string
|
numeric or string time |
Returns:
-
Type
-
boolean
(static) millsToInt(m) → {number}
- Source:
- Deprecated:
- Convert a number of milliseconds since 1970 UTC to an integer time HHMM.
This takes into account the local timezone.
- See:
-
- TimeUtils.toInt()
- DateTimeUtils.toMilliseconds()
- DateUtils.millsToInt()
Parameters:
| Name |
Type |
Description |
m |
number
|
number of milliseconds since 1970 UTC |
Returns:
HHMM
-
Type
-
number
(static) minutes(time) → {number}
- Description:
- Returns the minutes portion of a time in an integer representation formatted HHMM
- Source:
Parameters:
| Name |
Type |
Description |
time |
number
|
HHMM |
Returns:
-
Type
-
number
(static) minutesToTime(m) → {number}
- Description:
- Convert a number of minutes into standard time format (HHMM).
- Source:
Parameters:
| Name |
Type |
Description |
m |
number
|
number of minutes |
Returns:
HHMM
-
Type
-
number
(static) strToInt(sval) → {null|number}
- Description:
- Convert a string time into an integer time. If it is already a number, the number is returned.
- Source:
Parameters:
| Name |
Type |
Description |
sval |
string
|
"11:30 AM", "1130", "11:30pm", "11.30", accepts military time too, etc. |
Returns:
integer formatted as HHMM or null if not a time
-
Type
-
null
|
number
(static) toInt(dt) → {number}
- Description:
- Converts a date, string, or number into a time (HHMM) as an integer.
- Source:
Parameters:
| Name |
Type |
Description |
dt |
Date
|
number
|
string
|
The date, string, or number to convert |
Returns:
The time (HHMM) as an integer
-
Type
-
number
(static) totalMinutes(time) → {null|number}
- Description:
- Returns the total minutes in a time.
- Source:
Parameters:
| Name |
Type |
Description |
time |
number
|
HHMM |
Returns:
-
Type
-
null
|
number