Skip to content

Commit 24339bf

Browse files
x0sinaImMohammad20000
authored andcommitted
feat(date-picker): when today is selected, the time is set to 23:59
1 parent 1d78fa9 commit 24339bf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dashboard/src/components/common/date-picker.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,18 @@ export function DatePicker({
194194

195195
const now = new Date()
196196
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate())
197-
const selectedDateOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate())
197+
let selectedDateOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate())
198198

199199
if (minDate === undefined && selectedDateOnly < today) {
200200
selectedDate = new Date(now)
201+
selectedDateOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate())
201202
}
202203

203-
if (internalDate && !showTime) {
204+
const isToday = selectedDateOnly.getTime() === today.getTime()
205+
206+
if (isToday) {
207+
selectedDate.setHours(23, 59, 59, 999)
208+
} else if (internalDate && !showTime) {
204209
selectedDate.setHours(internalDate.getHours(), internalDate.getMinutes(), internalDate.getSeconds(), internalDate.getMilliseconds())
205210
} else {
206211
selectedDate.setHours(now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds())

0 commit comments

Comments
 (0)