Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Pass in locale for date.toLocaleString. (#2216)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba committed Mar 14, 2018
1 parent 8db49b6 commit eeb794c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ USER_SETTINGS=true
ENABLE_ANNOTATIONS=true
SCREENSHOTS_UPLOAD_BINARY=true

export NODE_ICU_DATA="$(pwd)/node_modules/full-icu"
export NO_UGLIFY=true
export NODE_ENV=dev
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ COPY build/shared /app/build/shared
COPY node_modules /app/node_modules
COPY bin/_run-docker /app/bin/
COPY build/screenshots.xpi /app/build/xpi/screenshots.xpi
ENV NODE_ICU_DATA="/app/node_modules/full-icu"
RUN cd app && npm install

CMD /app/bin/_run-docker
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"fluent-intl-polyfill": "0.1.0",
"fluent-langneg": "0.1.0",
"fluent-react": "0.4.1",
"full-icu": "1.2.1",
"jpm": "1.3.1",
"keygrip": "1.0.2",
"mobile-detect": "1.3.7",
Expand Down
6 changes: 5 additions & 1 deletion server/src/pages/shot/time-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ exports.TimeDiff = class TimeDiff extends React.Component {
if (!(d instanceof Date)) {
d = new Date(d);
}
if (this.props.userLocales && this.props.userLocales.length) {
return d.toLocaleString(this.props.userLocales[0]);
}
return d.toLocaleString();
}
};

exports.TimeDiff.propTypes = {
date: PropTypes.number
date: PropTypes.number,
userLocales: PropTypes.array
}
5 changes: 3 additions & 2 deletions server/src/pages/shot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class Body extends React.Component {

const linkTextShort = shot.urlDisplay;

const timeDiff = <TimeDiff date={shot.createdDate} />;
const timeDiff = <TimeDiff date={shot.createdDate} userLocales={this.props.userLocales} />;
let expiresDiff = null;
if (this.props.isOwner) {
expiresDiff = <span className="expire-widget">
Expand Down Expand Up @@ -567,7 +567,8 @@ Body.propTypes = {
showSurveyLink: PropTypes.bool,
shot: PropTypes.object,
staticLink: PropTypes.func,
userAgent: PropTypes.string
userAgent: PropTypes.string,
userLocales: PropTypes.array
};

class ExpireWidget extends React.Component {
Expand Down

0 comments on commit eeb794c

Please # to comment.