Skip to content

Commit

Permalink
Merge pull request #29 from navikt/feature/kibanalink
Browse files Browse the repository at this point in the history
Justerer kibanalink dato intervaller etter timezone
  • Loading branch information
arefsahl authored Nov 8, 2024
2 parents 63b4467 + 909c00e commit fc47bdf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/services/kibana.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import { env } from '~/services/env.server'

export function kibanaLink(behandling: BehandlingDto) {
const application = env.penApplication
const minuteMultiplier = 60000

const startTime = new Date(
new Date(behandling.opprettet).getTime() - 5,
const adjustToLocalTime = (date: Date) => {
const offset = date.getTimezoneOffset() * minuteMultiplier
return new Date(date.getTime() - offset)
}

const startTime = adjustToLocalTime(
new Date(new Date(behandling.opprettet).getTime() - 5 * minuteMultiplier)
).toISOString()
const endTime = new Date(
new Date(behandling.sisteKjoring).getTime() + 5,
const endTime = adjustToLocalTime(
new Date(new Date(behandling.sisteKjoring).getTime() + 5 * minuteMultiplier)
).toISOString()

const refreshInterval = `(refreshInterval:(pause:!t,value:0),time:(from:'${startTime}',to:'${endTime}'))`
Expand Down

0 comments on commit fc47bdf

Please sign in to comment.