Skip to content

Commit

Permalink
fix(app): consistent date formatting for calibration last modified ti…
Browse files Browse the repository at this point in the history
…me (#7003)

Format all dates associated with the last modified date of calibration data in the same manner for
consistency

Closes #7002
  • Loading branch information
b-cooper authored Nov 16, 2020
1 parent 3db0fea commit 3b3d75d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
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

0 comments on commit 3b3d75d

Please sign in to comment.