Skip to content

Commit 2d895c0

Browse files
committed
fix: Day view intervals start at wrong time #13
1 parent e997d39 commit 2d895c0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/component/utils/timestamp.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@ export function updateFormatted (timestamp) {
228228

229229
export function getDayOfYear (timestamp) {
230230
if (timestamp.year === 0) return
231-
const ts = new Date(timestamp.year, timestamp.month - 1, timestamp.day)
231+
const ts = new Date(Date.UTC(timestamp.year, timestamp.month - 1, timestamp.day, 0, 0))
232232
return date.getDayOfYear(ts)
233233
}
234234

235235
export function getWorkWeek (timestamp) {
236236
if (timestamp.year === 0) return
237-
const ts = new Date(timestamp.year, timestamp.month - 1, timestamp.day)
237+
const ts = new Date(Date.UTC(timestamp.year, timestamp.month - 1, timestamp.day, 0, 0))
238238
return date.getWeekOfYear(ts)
239239
}
240240

241241
export function getWeekday (timestamp) {
242242
// [bug] this code has issues. If 1st day of the month is 1 day of week
243243
// it comes back with day of week as 7.
244244
// if (timestamp.hasDay) {
245-
// const ts = new Date(timestamp.year, timestamp.month - 1, timestamp.day)
245+
// const ts = new Date(Date.UTC(timestamp.year, timestamp.month - 1, timestamp.day, 0, 0))
246246
// return date.getDayOfWeek(ts)
247247
// }
248248

@@ -430,7 +430,8 @@ export function createNativeLocaleFormatter (locale, getOptions) {
430430
const intlFormatter = new Intl.DateTimeFormat(locale || void 0, getOptions(timestamp, short))
431431
// const time = `${padNumber(timestamp.hour, 2)}:${padNumber(timestamp.minute, 2)}`
432432
// const date = timestamp.date
433-
return intlFormatter.format(new Date(timestamp.year, timestamp.month - 1, timestamp.day, timestamp.hour, timestamp.minute))
433+
// return intlFormatter.format(new Date(`${date}T${time}:00+00:00`))
434+
return intlFormatter.format(new Date(Date.UTC(timestamp.year, timestamp.month - 1, timestamp.day, timestamp.hour, timestamp.minute)))
434435
} catch (e) {
435436
return ''
436437
}

0 commit comments

Comments
 (0)