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

Commit

Permalink
Payments page uses relative and ISO 8601 dates
Browse files Browse the repository at this point in the history
- Add [moment.js](https://github.com/moment/moment/)
- moment supports many [date localizations](http://momentjs.com/docs/#/i18n/) - to be added later

Fix #4294

Auditors: @jkup @mrose17

Test Plan:
1. In Prefeences > Payments, see Status and look for the "Next contribution: in {n} days".
2. In Payment history, check that contribution dates are in ISO 8601 format (YYYY-MM-DD).
3. Also look near the bottom for "Next contribution :in {n} days".
  • Loading branch information
ayumi committed Sep 29, 2016
1 parent 74790fc commit c165cbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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 @@ -824,9 +825,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 @@ -841,9 +843,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 @@ -1511,9 +1514,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 c165cbf

Please sign in to comment.