From 70f38cf1d599765a3896a51ac34230495bd544e7 Mon Sep 17 00:00:00 2001 From: Sigve Kvalsvik Date: Tue, 31 Oct 2017 10:33:44 +0100 Subject: [PATCH] Localize market history dates to US/rest of the world format close #644 --- app/assets/locales/locale-en.json | 3 ++- app/components/Exchange/MarketHistory.jsx | 3 ++- app/components/Utility/BlockDate.jsx | 4 ++-- package.json | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/locales/locale-en.json b/app/assets/locales/locale-en.json index edbfe2d1b3..2cee1aec05 100644 --- a/app/assets/locales/locale-en.json +++ b/app/assets/locales/locale-en.json @@ -3,7 +3,8 @@ "formats": { "date": { "short_custom": "%e %b '%y", - "market_history": "%m/%e %H:%M:%S" + "market_history": "%e/%m %H:%M:%S", + "market_history_us": "%m/%e %H:%M:%S" } } }, diff --git a/app/components/Exchange/MarketHistory.jsx b/app/components/Exchange/MarketHistory.jsx index 9b1029c208..dc80e7f888 100644 --- a/app/components/Exchange/MarketHistory.jsx +++ b/app/components/Exchange/MarketHistory.jsx @@ -16,6 +16,7 @@ const {operations} = grapheneChainTypes; import BlockDate from "../Utility/BlockDate"; import counterpart from "counterpart"; import ReactTooltip from "react-tooltip"; +import getLocale from "browser-locale"; class MarketHistory extends React.Component { constructor(props) { @@ -147,7 +148,7 @@ class MarketHistory extends React.Component { {parsed_order.receives} {parsed_order.pays} - {counterpart.localize(new Date(order.time), {type: "date", format: "market_history"})} + {counterpart.localize(new Date(order.time), {type: "date", format: getLocale().toLowerCase().indexOf("en-us") !== -1 ? "market_history_us": "market_history"})} ); diff --git a/app/components/Utility/BlockDate.jsx b/app/components/Utility/BlockDate.jsx index 647ddf2e35..d3399a6403 100644 --- a/app/components/Utility/BlockDate.jsx +++ b/app/components/Utility/BlockDate.jsx @@ -4,6 +4,7 @@ import {connect} from "alt-react"; import BlockchainStore from "stores/BlockchainStore"; import BlockchainActions from "actions/BlockchainActions"; import ReactTooltip from "react-tooltip"; +import getLocale from "browser-locale"; /** * @brief displays block's date and time based on block number @@ -15,7 +16,7 @@ import ReactTooltip from "react-tooltip"; class BlockDate extends React.Component { static defaultProps = { - format: "market_history", + format: getLocale().toLowerCase().indexOf("en-us") !== -1 ? "market_history_us": "market_history", tooltip: false, component: "span" } @@ -31,7 +32,6 @@ class BlockDate extends React.Component { render() { const {block, tooltip, component, format} = this.props; - if (!block) return React.createElement(component); return ( React.createElement(component, {className: tooltip ? "tooltip": "", "data-tip": tooltip ? block.timestamp : ""}, diff --git a/package.json b/package.json index 1435deff13..a98af4d3cd 100644 --- a/package.json +++ b/package.json @@ -127,6 +127,7 @@ "alt-react": "0.0.1", "bignumber.js": "^4.0.0", "bitsharesjs": "^1.4.1", + "browser-locale": "^1.0.3", "classnames": "^2.2.1", "cookies-js": "^1.2.1", "counterpart": "^0.17.1",