Skip to content

Commit

Permalink
Use Date.now() for getting current date
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpetro committed Feb 11, 2024
1 parent c97d6de commit d0bfe9c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/irrigation-events/viewmodel-transform.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { compareAsc, roundToNearestMinutes } from 'date-fns'
import { IrrigationEventViewmodel } from './dto/irrigation-event-viewmodel.dto'
import { DeviceState } from './enums/device-state.interface'
import { Warning } from './enums/warning.interface'
// import { DeviceEvents } from './domain/device-events'
import { DeviceEvents } from './interfaces/device-events.interface'

const convertTimestampToViewmodel = (timestamp: Date): string =>
const convertTimestampToViewmodel = (timestamp: Parameters<typeof roundToNearestMinutes>[0]): string =>
roundToNearestMinutes(timestamp, {
nearestTo: 1,
roundingMethod: 'trunc',
Expand Down Expand Up @@ -44,7 +43,7 @@ function createViewmodelsFromDeviceEvents({ events, currentDeviceState }: Device
currentDeviceState === DeviceState.ON
? {
startDate: convertTimestampToViewmodel(event.timestamp),
endDate: convertTimestampToViewmodel(new Date()),
endDate: convertTimestampToViewmodel(Date.now()),
title: event.deviceName,
deviceId: event.deviceId,
currentlyOn: true,
Expand Down

0 comments on commit d0bfe9c

Please sign in to comment.