Skip to content

Commit

Permalink
Localize market history dates to US/rest of the world format close bi…
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Oct 31, 2017
1 parent f29e566 commit 70f38cf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion app/components/Exchange/MarketHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -147,7 +148,7 @@ class MarketHistory extends React.Component {
<td>{parsed_order.receives}</td>
<td>{parsed_order.pays}</td>
<td className="tooltip" data-tip={new Date(order.time)}>
{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"})}
</td>
</tr>
);
Expand Down
4 changes: 2 additions & 2 deletions app/components/Utility/BlockDate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
Expand All @@ -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 : ""},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 70f38cf

Please sign in to comment.