CivilTime
(and its siblings) represents a time corresponding to the requirements of ISO-8601.
This means specifically that days are 24 hours long and begin and end at midnight.
The constructor may only be called as such. It takes between 2 and 4 numeric arguments.
hours
hour of the dayminutes
minutes of the hourseconds
seconds of the minutes (default: 0)milliseconds
milliseconds of the second (default: 0)microseconds
microseconds of the millisecond (default: 0)nanoseconds
nanoseconds of the microseconds (default: 0)
The .hour
property represents the hour of the CivilTime
.
The .minute
property represents the minute of the hour of the CivilTime
.
The .second
property represents the second of the minute of the CivilTime
.
The .millisecond
property represents the sub-second component of the second of the CivilTime
with millisecond precision. It will have a value between 0 and 999.
The .microsecond
property represents the sub-millisecond component of the millisecond of the CivilTime
with microsecond precision. It will have a value between 0 and 999.
The .nanosecond
property represents the sub-microsecond component of the microsecond of the CivilTime
with nanosecond precision. It will have a value between 0 and 999.
datetime.plus({ hours?, minutes?, seconds?, milliseconds?, microseconds?, nanoseconds? }) : CivilTime
Creates a new CivilTime
object by adding (subtracting for negative values) values to its members.
The specified values must be numeric if specified.
The algorithm is such that:
- the individual values are added to the existing values.
- the range of
nanoseconds
is ensured to be between 0 and 999 by adjusting themicroseconds
- the range of
microseconds
is ensured to be between 0 and 999 by adjusting themilliseconds
- the range of
milliseconds
is ensured to be between 0 and 999 by adjusting theseconds
- the range of
seconds
is ensured to be between 0 and 59 by adjusting theminutes
- the range of
minutes
is ensured to be between 0 and 59 by adjusting thehours
- the range of
hours
is ensured to be between 0 and 23
datetime.with({ hours?, minutes?, seconds?, milliseconds?, microseconds?, nanoseconds? }) : CivilTime
Creates a new CivilTime
object by overriding specified values to its members.
The specified values must be numeric if specified.
Combines this CivilTime
with the passed CivilDate
to create a new CivilDateTime
object.
.toString()
creates an ISO-8601 compliant string in the format:
hour
:minute
:second
.nanosecond
.
The hours
, minutes
and seconds
are 0-padded to a minimum of 2 digits.
nanoseconds
is 0-padded to a minimum of 9 digits.
Equivalent to datetime.toString()
Creates a new CivilTime
by parsing an ISO-8601 string in the format created by .toString()
.