Commit aa5f3a2c authored by Marek Veselý's avatar Marek Veselý
Browse files

Merge branch 'fix-analyst-timestamps' into 'main'

fix: analyst timestamp errors

See merge request inject/frontend!371
parents 3a0fe6f5 a3d4083b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ const useFormatTimestamp = () => {
  const { exercise } = useContext(ExerciseContext)
  const timeRelative = useRelativeTime()

  return timeRelative
  return timeRelative || !exercise.exerciseStart
    ? (timestamp: string | null) =>
        formatTimestampRelative(timestamp, exercise.exerciseStart)
    : formatTimestamp
+2 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import { timeFormat } from 'd3-time-format'
import type { SVGProps } from 'react'

export const formatTimestamp = (timestamp: string | null) => {
  const date = new Date(timestamp || '')
  const date = new Date(timestamp || 0)
  return `${date.toISOString().substring(0, 10)} ${date.toLocaleTimeString()}`
}

@@ -30,8 +30,7 @@ export const formatTimestampRelative = (
  start: string | null
) =>
  new Date(
    new Date(timestamp || '').getTime() -
      (start ? new Date(start).getTime() : 0)
    new Date(timestamp || 0).getTime() - (start ? new Date(start).getTime() : 0)
  )
    .toISOString()
    .substring(11, 19)