DayTime
internal
This class encapsulates time of day calculations.
The goal is to describe a "day" (a 24-hour period) that starts at a specific time (other than midnight). In a calendar day view, this would look like this:
startShift=0 startShift='12:00'
00:00 +-------+ 12:00 +-------+
| | | |
01:00 |- - - -| 13:00 |- - - -|
... ...
| | | |
08:00 |- - - -| <-- timeStart --> 20:00 |- - - -|
| | | |
09:00 |- - - -| 21:00 |- - - -|
| | | |
10:00 |- - - -| 22:00 |- - - -|
| | | |
11:00 |- - - -| 23:00 |- - - -|
| | | |
12:00 |- - - -| 00:00 |- - - -|
| | | |
13:00 |- - - -| 01:00 |- - - -|
| | | |
14:00 |- - - -| 02:00 |- - - -|
| | | |
15:00 |- - - -| 03:00 |- - - -|
| | | |
16:00 |- - - -| 04:00 |- - - -|
| | | |
17:00 |- - - -| <-- timeEnd --> 05:00 |- - - -|
| | | |
... ...
| | | |
23:00 |- - - -| 11:00 |- - - -|
| | | |
00:00 +-------+ 12:00 +-------+
In a horizontal format with X for times to render:
startShift = 0
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
| | | ... | |XXX|XXX| ... |XXX|XXX| | ... | |
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
00 01 02 07 08 09 10 15 16 17 18 23 00
^ ^
timeStart timeEnd
startShift = '12:00'
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
| | | ... | |XXX|XXX|X ... X|XXX|XXX| | ... | |
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
12 13 14 19 20 21 22 03 04 05 06 11 12
^ ^
timeStart timeEnd
When the day wraps over midnight, it is describing this (note timeEnd < timeStart):
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
|XXX|XXX|X ... X|XXX| | | ... | | |XXX|X ... X|XXX|
+---+---+--- --+---+---+---+-- --+---+---+---+-- --+---+
00 01 02 04 05 06 07 18 19 20 21 23 00
^ ^
timeEnd timeStart
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Either the hour number or a 24 hour
HH:MMstring denoting the start time for the day. This is midnight by default. -
Either the hour number or a 24 hour
HH:MMstring denoting the last visible time of day. You can also set this value to a ms timestamp representing time from midnight. -
Either the hour number or a 24 hour
HH:MMstring denoting the first visible time of day. You can also set this value to a ms timestamp representing time from midnight.
Properties
Properties are getters/setters or publicly accessible variables on this class-
The
DayTimeinstance representing a canonical calendar day (starting at midnight).
-
The number of milliseconds from the day's
startShiftto itstimeStart. -
The
Dateobject for the most recently started, shifted day. The time of thisDatewill be thestartShift. It is possible for this date to be yesterday on a midnight-based calendar. For example, if thestartShiftis 6PM and the current time is 6AM on May 20, this value will be 6PM of May 19 (the most recently started day).