Fixes time zone based stuff
This commit is contained in:
@@ -29,7 +29,9 @@
|
||||
|
||||
const seed = untrack(() => {
|
||||
if (initialValue) {
|
||||
const d = new Date(initialValue)
|
||||
// Append Z if no timezone indicator is present so it's always parsed as UTC
|
||||
const normalized = /Z$|[+-]\d{2}:?\d{2}$/.test(initialValue) ? initialValue : initialValue + 'Z'
|
||||
const d = new Date(normalized)
|
||||
return { month: d.getMonth(), day: d.getDate(), year: d.getFullYear(), timeIndex: d.getHours() * 4 + Math.round(d.getMinutes() / 15) }
|
||||
}
|
||||
const today = new Date()
|
||||
@@ -48,10 +50,9 @@
|
||||
})
|
||||
|
||||
$effect(() => {
|
||||
const pad = (n: number) => n.toString().padStart(2, '0')
|
||||
const hour = Math.floor(timeIndex / 4)
|
||||
const minute = (timeIndex % 4) * 15
|
||||
value = new Date(`${year}-${pad(month + 1)}-${pad(day)}T${pad(hour)}:${pad(minute)}`).toISOString()
|
||||
value = new Date(year, month, day, hour, minute).toISOString()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user