Skip to content

Commit 1095e94

Browse files
committed
fix(single-value): Convert date metrics to correct timezone.
1 parent cec49c4 commit 1095e94

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

CHANGE_LOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.0.7
2+
3+
## Changes
4+
5+
- Single values now convert dates to the timezone of the app if possible.
6+
17
# 0.0.6
28

39
## Changes

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lodash-es": "^4.17.21",
5151
"react-query": "^3.39.0",
5252
"recoil": "^0.6.1",
53-
"@modbros/dashboard-sdk": "0.0.11",
54-
"@modbros/dashboard-core": "0.0.18"
53+
"@modbros/dashboard-sdk": "0.0.12",
54+
"@modbros/dashboard-core": "0.0.19"
5555
}
5656
}

src/widgets/SingleValue/SingleValue.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
useMetricFieldValueType,
1111
useNumberField,
1212
useSelectField,
13-
useStringField
13+
useStringField,
14+
useConvertDateToTimezone
1415
} from '@modbros/dashboard-sdk'
1516
import styled from 'styled-components'
1617
import { isEmpty, isNumber } from 'lodash-es'
@@ -60,6 +61,8 @@ const Value: FunctionComponent<ChannelValueProp> = (props) => {
6061
const { channelValue } = props
6162
const { value } = channelValue
6263

64+
const convertDate = useConvertDateToTimezone()
65+
6366
const precision = useNumberField({ field: 'precision', defaultValue: 0 })
6467
const valueFont = useFontField({ field: 'value_font' })
6568
const valueFontSize = useNumberField({ field: 'value_font_size' })
@@ -86,7 +89,7 @@ const Value: FunctionComponent<ChannelValueProp> = (props) => {
8689
}
8790

8891
if (valueType === 'date') {
89-
const dateValue = new Date(v)
92+
const dateValue = convertDate(new Date(v))
9093
const time =
9194
timeFormat === '12h'
9295
? format12h(dateValue, hideSeconds)

0 commit comments

Comments
 (0)