Skip to content

Commit 57cadb4

Browse files
committed
fix(timestamp): '00:00' is a valid time
This means, even when a time is not given, the result will be '00:00', which mimics 'Date' functionality. So, there will always be time (.hasTime = true)
1 parent 9621ad2 commit 57cadb4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ui/src/utils/Timestamp.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ export function parsed (input) {
253253
year: parseInt(parts[ 1 ], 10),
254254
month: parseInt(parts[ 2 ], 10),
255255
day: parseInt(parts[ 4 ], 10) || 1,
256-
hour: parseInt(parts[ 6 ], 10) || 0,
257-
minute: parseInt(parts[ 8 ], 10) || 0,
256+
hour: !isNaN(parseInt(parts[ 6 ], 10)) ? parseInt(parts[ 6 ], 10) : 0,
257+
minute: !isNaN(parseInt(parts[ 8 ], 10)) ? parseInt(parts[ 8 ], 10) : 0,
258258
weekday: 0,
259259
doy: 0,
260260
workweek: 0,
261261
hasDay: !!parts[ 4 ],
262-
hasTime: !isNaN(parts[ 6 ]) && !isNaN(parts[ 8 ]),
262+
hasTime: true, // there is always time because no time is '00:00', which is valid
263263
past: false,
264264
current: false,
265265
future: false,
@@ -306,7 +306,7 @@ export function parseDate (date, utc = false) {
306306
doy: 0,
307307
workweek: 0,
308308
hasDay: true,
309-
hasTime: !!(date[ `get${ UTC }Hours` ]() !== 0 && date[ `get${ UTC }Minutes` ]() !== 0),
309+
hasTime: true, // Date always has time, even if it is '00:00'
310310
past: false,
311311
current: false,
312312
future: false,
@@ -501,7 +501,7 @@ export function updateDisabled (timestamp, disabledBefore, disabledAfter, disabl
501501
* @returns The modified {@link Timestamp}
502502
*/
503503
export function updateFormatted (timestamp) {
504-
timestamp.hasTime = !(timestamp.hour === 0 && timestamp.minute === 0)
504+
timestamp.hasTime = true
505505
timestamp.time = getTime(timestamp)
506506
timestamp.date = getDate(timestamp)
507507
timestamp.weekday = getWeekday(timestamp)

0 commit comments

Comments
 (0)