Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): consistent date formatting for calibration last modified time #7003

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/components/CalibrationPanels/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import { format } from 'date-fns'
import type { JogAxis } from '../../http-api-client'
import type { VectorTuple } from '../../sessions/types'

Expand All @@ -17,3 +18,9 @@ export function formatJogVector(
}
return vector
}

export function formatLastModified(lastModified: string | null): string {
return typeof lastModified === 'string'
? format(new Date(lastModified), 'MMMM dd, yyyy HH:mm')
: 'unknown'
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ import {
INTENT_PIPETTE_OFFSET,
INTENT_TIP_LENGTH_OUTSIDE_PROTOCOL,
} from '../CalibrationPanels'
import { formatLastModified } from '../CalibrationPanels/utils'
import { Portal } from '../portal'
import { getDisplayNameForTipRack, formatLastModified } from './utils'
import { getDisplayNameForTipRack } from './utils'

import type { Mount } from '../../pipettes/types'
import type { State } from '../../types'
Expand Down
7 changes: 0 additions & 7 deletions app/src/components/InstrumentSettings/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import { format } from 'date-fns'
import { getLabwareDisplayName } from '@opentrons/shared-data'
import { findLabwareDefWithCustom } from '../../findLabware'

Expand All @@ -22,9 +21,3 @@ export function getDisplayNameForTipRack(
? getLabwareDisplayName(definition)
: `${UNKNOWN_CUSTOM_LABWARE}`
}

export function formatLastModified(lastModified: string | null): string {
return typeof lastModified === 'string'
? format(new Date(lastModified), 'MMMM dd, yyyy HH:mm')
: 'unknown'
}
4 changes: 2 additions & 2 deletions app/src/components/RobotSettings/DeckCalibrationControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import * as React from 'react'
import { useSelector, useDispatch } from 'react-redux'
import { format } from 'date-fns'
import {
Icon,
Text,
Expand Down Expand Up @@ -30,6 +29,7 @@ import {
REQUIRED,
RECOMMENDED,
} from '../InlineCalibrationWarning'
import { formatLastModified } from '../CalibrationPanels/utils'

import type { State, Dispatch } from '../../types'
import type {
Expand Down Expand Up @@ -66,7 +66,7 @@ const buildDeckLastCalibrated: (
}
const datestring =
typeof data.lastModified === 'string'
? format(new Date(data.lastModified), 'yyyy-MM-dd HH:mm')
? formatLastModified(data.lastModified)
: 'unknown'
const prefix = calData =>
typeof data?.source === 'string'
Expand Down
7 changes: 2 additions & 5 deletions app/src/components/RobotSettings/PipetteOffsetItem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import * as React from 'react'
import { format } from 'date-fns'

import type { LabwareDefinition2 } from '@opentrons/shared-data'
import { getLabwareDisplayName } from '@opentrons/shared-data'
Expand Down Expand Up @@ -31,6 +30,7 @@ import {
RECOMMENDED,
REQUIRED,
} from '../InlineCalibrationWarning'
import { formatLastModified } from '../CalibrationPanels/utils'
import type { AttachedPipette, PipetteCalibrations } from '../../pipettes/types'
import type {
PipetteOffsetCalibration,
Expand Down Expand Up @@ -78,10 +78,7 @@ function getCalibrationDate(
fontStyle={FONT_STYLE_ITALIC}
marginTop={SPACING_1}
>
{`${LAST_CALIBRATED}: ${format(
new Date(calibration.lastModified),
'MMMM d y HH:mm'
)}`}
{`${LAST_CALIBRATED}: ${formatLastModified(calibration.lastModified)}`}
</Text>
)
}
Expand Down