-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove moment usage from main codebase #880
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ table.table.table-in-card.c-payments(:class='{"is-editing": paymentsType === "ed | |
// TODO: replace condition to indicate whether or not the payment date is < or > than the current date using payment.paymentStatusText | ||
i18n.c-user-month( | ||
:class='index === 0 ? "has-text-1" : "pill is-danger"' | ||
:args='{date: moment(payment.date).format("MMMM DD")}' | ||
:args='{date: dueDate(payment.date) }' | ||
) Due {date} | ||
td.c-payments-amount(v-if='paymentsType !== "edit"') | ||
|
||
|
@@ -66,7 +66,7 @@ table.table.table-in-card.c-payments(:class='{"is-editing": paymentsType === "ed | |
|
||
td | ||
.c-actions | ||
.c-actions-month(:class='!(index !== 0 && paymentsType === "todo") ? "has-text-1" : "pill is-danger"') {{ moment(payment.date).format('MMMM D') }} | ||
.c-actions-month(:class='!(index !== 0 && paymentsType === "todo") ? "has-text-1" : "pill is-danger"') {{ dueDate(payment.date) }} | ||
payments-list-menu.c-actions-menu( | ||
v-if='paymentsType !== "edit"' | ||
:payment='payment' | ||
|
@@ -94,8 +94,7 @@ import AvatarUser from '@components/AvatarUser.vue' | |
import Tooltip from '@components/Tooltip.vue' | ||
import PaymentsListMenu from '@containers/payments/PaymentsListMenu.vue' | ||
import currencies from '@view-utils/currencies.js' | ||
import moment from 'moment' | ||
|
||
import { humanDate } from '@view-utils/humanDate.js' | ||
export default { | ||
name: 'PaymentsList', | ||
components: { | ||
|
@@ -119,7 +118,6 @@ export default { | |
}, | ||
data () { | ||
return { | ||
moment, | ||
// Temp | ||
tableChecked: false | ||
} | ||
|
@@ -157,6 +155,10 @@ export default { | |
this.payments.map(payment => { | ||
payment.checked = this.tableChecked | ||
}) | ||
}, | ||
dueDate (datems) { | ||
const date = datems || new Date() // remote new Date() when dealing with real data. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you enforce consistency here and everywhere else in the type usage? I.e. either So in this case, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value is a clean solution. Changed, as well as the other comments! |
||
return humanDate(date, { month: 'short', day: 'numeric' }) | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function humanDate (datems, opts = {}) { | ||
const date = new Date(datems) | ||
const locale = navigator.languages ? navigator.languages[0] : navigator.language | ||
return date.toLocaleDateString(locale, opts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to fetch the locale each time this function is called, that can be done once at the top of this file. Then this function can be a one-liner: return new Date(datems).toLocaleDateString(locale, opts) |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below re
Date.now()
usage