Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #4370 from brave/fix/ledger-date-l10n
Browse files Browse the repository at this point in the history
Payment prefs: use relative local and ISO 8601 dates
  • Loading branch information
ayumi committed Sep 29, 2016
2 parents e7e7fc6 + 18cf5df commit ee858f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
25 changes: 16 additions & 9 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const getSetting = require('../settings').getSetting
const SortableTable = require('../components/sortableTable')
const Button = require('../components/button')
const searchProviders = require('../data/searchProviders')
const moment = require('moment')

const adblock = appConfig.resourceNames.ADBLOCK
const cookieblock = appConfig.resourceNames.COOKIEBLOCK
Expand Down Expand Up @@ -825,9 +826,10 @@ class PaymentsTab extends ImmutableComponent {
if (!ledgerData.get('reconcileStamp')) {
return null
}
let nextReconcileDate = formattedDateFromTimestamp(ledgerData.get('reconcileStamp'))
let l10nDataArgs = {
reconcileDate: nextReconcileDate
const timestamp = ledgerData.get('reconcileStamp')
const nextReconcileDateRelative = formattedTimeFromNow(timestamp)
const l10nDataArgs = {
reconcileDate: nextReconcileDateRelative
}
return <div className='paymentHistoryFooter'>
<div className='nextPaymentSubmission'>
Expand All @@ -842,9 +844,10 @@ class PaymentsTab extends ImmutableComponent {
if (!ledgerData.get('reconcileStamp')) {
return null
}
const nextReconcileDate = formattedDateFromTimestamp(ledgerData.get('reconcileStamp'))
const timestamp = ledgerData.get('reconcileStamp')
const nextReconcileDateRelative = formattedTimeFromNow(timestamp)
const l10nDataArgs = {
reconcileDate: nextReconcileDate
reconcileDate: nextReconcileDateRelative
}
return <div className='nextReconcileDate' data-l10n-args={JSON.stringify(l10nDataArgs)} data-l10n-id='statusNextReconcileDate' />
}
Expand Down Expand Up @@ -1385,7 +1388,8 @@ class AboutPreferences extends React.Component {
ipc.on(messages.FLASH_UPDATED, (e, flashInstalled) => {
this.setState({ flashInstalled })
})
ipc.on(messages.LANGUAGE, (e, {languageCodes}) => {
ipc.on(messages.LANGUAGE, (e, {langCode, languageCodes}) => {
moment.locale(langCode)
this.setState({ languageCodes })
})
ipc.send(messages.REQUEST_LANGUAGE)
Expand Down Expand Up @@ -1512,9 +1516,12 @@ class AboutPreferences extends React.Component {
}
}

let formattedDateFromTimestamp = function (timestamp) {
var date = new Date(timestamp)
return date.toLocaleDateString()
function formattedDateFromTimestamp (timestamp) {
return moment(new Date(timestamp)).format('YYYY-MM-DD')
}

function formattedTimeFromNow (timestamp) {
return moment(new Date(timestamp)).fromNow()
}

module.exports = <AboutPreferences />
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"ledger-geoip": "^0.8.72",
"ledger-publisher": "^0.8.74",
"lru_cache": "^1.0.0",
"moment": "^2.15.1",
"qr-image": "^3.1.0",
"random-lib": "2.1.0",
"react": "^15.0.1",
Expand Down

0 comments on commit ee858f8

Please sign in to comment.