diff --git a/package.json b/package.json index b1da21a..e12e17e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "axios": "^0.18.0", "eslint-plugin-jest": "^21.12.3", "expo": "^25.0.0", + "moment": "^2.21.0", "native-base": "^2.3.9", "react": "16.2.0", "react-native": "0.52.0", diff --git a/src/components/Chart/Chart.js b/src/components/Chart/Chart.js index 39a5896..f375f6c 100644 --- a/src/components/Chart/Chart.js +++ b/src/components/Chart/Chart.js @@ -1,6 +1,7 @@ // @flow import * as React from 'react' +import moment from 'moment' import { Dimensions, StyleSheet, Text, View } from 'react-native' import { VictoryAxis, @@ -139,19 +140,12 @@ class Chart extends React.Component { // ticks are >= 24 hours apart if (Math.abs(dates[adjacentIndex] - date) > 1000 * 60 * 60 * 24) { const year = date.getFullYear() - return date.toLocaleString('en-US', { - month: 'short', - day: 'numeric', - year: year !== currentYear ? 'numeric' : undefined, - }) + const format = year !== currentYear ? 'l' : 'MMM D' + return moment(date).format(format) } const showMinutes = date.getMinutes() !== 0 - return date.toLocaleString('en-US', { - hour: 'numeric', - minute: showMinutes ? 'numeric' : undefined, - hour12: true, - }) + return moment(date).format(showMinutes ? 'LT' : 'h A') }} />