···11<script lang="ts">
22- import type { MouseEventParams, UTCTimestamp } from 'lightweight-charts'
22+ import type { BusinessDay, MouseEventParams, UTCTimestamp } from 'lightweight-charts'
33 import { onDestroy } from 'svelte'
44 import type { Chart, DataPoint, Line } from './chart'
55 import { hexColors } from './color'
···6767 return
6868 }
6969 // time is in the same format that we supplied to setData
7070- const time = param.time as UTCTimestamp
7070+ if (typeof param.time !== 'object') {
7171+ console.error('time is not a BusinessDay:', param.time)
7272+ return
7373+ }
7474+ const time = param.time as BusinessDay
71757276 for (const line of $chart.lines) {
7373- const dataPoint = findDayEndDataPoint(line.data, time)
7777+ const maxDate = new Date(time.year, time.month - 1, time.day, 23, 59, 59, 999)
7878+ const maxTimestamp = (maxDate.getTime() / 1000) as UTCTimestamp
7979+ const dataPoint = findDayEndDataPoint(line.data, maxTimestamp)
7480 if (dataPoint) {
7581 values.push({
7682 line: line,