forked from ddrilling/asb_cloud_front
Начат перенос методов и типов для работы с датами
This commit is contained in:
parent
10cf64b4d6
commit
16af0d66c1
@ -9,9 +9,10 @@ import { WellIcon, WellIconState } from './icons/WellIcon'
|
|||||||
import { ReactComponent as DepositIcon } from '../images/DepositIcon.svg'
|
import { ReactComponent as DepositIcon } from '../images/DepositIcon.svg'
|
||||||
import { ReactComponent as ClusterIcon } from '../images/ClusterIcon.svg'
|
import { ReactComponent as ClusterIcon } from '../images/ClusterIcon.svg'
|
||||||
import { DepositDto } from '../services/api'
|
import { DepositDto } from '../services/api'
|
||||||
|
import { RawDate } from '../utils/DateTimeUtils'
|
||||||
|
|
||||||
export const getWellState = (idState?: number): WellIconState => idState === 1 ? 'active' : 'unknown'
|
export const getWellState = (idState?: number): WellIconState => idState === 1 ? 'active' : 'unknown'
|
||||||
export const checkIsWellOnline = (lastTelemetryDate?: string | number | Date | null): boolean => {
|
export const checkIsWellOnline = (lastTelemetryDate?: RawDate): boolean => {
|
||||||
if (!lastTelemetryDate) return false
|
if (!lastTelemetryDate) return false
|
||||||
return Date.now() - +new Date(lastTelemetryDate) < 600_000
|
return Date.now() - +new Date(lastTelemetryDate) < 600_000
|
||||||
}
|
}
|
||||||
|
5
src/utils/DateTimeUtils.ts
Normal file
5
src/utils/DateTimeUtils.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export type RawDate = number | string | Date
|
||||||
|
|
||||||
|
export function isRawDate(value: unknown): value is RawDate {
|
||||||
|
return isNaN(new Date(value as RawDate).getTime())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user