-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[NoQA] feat: Remove moment from the project (Except Datepicker) #28175
Changes from all commits
189f2b9
7c18da2
503eab3
b5016aa
93813c0
71391a1
3c86b0f
0cd0b9f
8a6dd64
84b7beb
42830bc
137d9aa
7538e54
e68a84a
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import _ from 'underscore'; | ||
import lodashGet from 'lodash/get'; | ||
import Onyx from 'react-native-onyx'; | ||
import moment from 'moment'; | ||
import {isBefore} from 'date-fns'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import * as API from '../API'; | ||
import CONST from '../../CONST'; | ||
|
@@ -460,7 +460,7 @@ function isBlockedFromConcierge(blockedFromConciergeNVP) { | |
return false; | ||
} | ||
|
||
return moment().isBefore(moment(blockedFromConciergeNVP.expiresAt), 'day'); | ||
return isBefore(new Date(), new Date(blockedFromConciergeNVP.expiresAt)); | ||
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. I think this is incorrect again. It should be 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. Here is correct again: |
||
} | ||
|
||
function triggerNotifications(onyxUpdates) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import React, {useEffect} from 'react'; | |
import PropTypes from 'prop-types'; | ||
import lodashGet from 'lodash/get'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import moment from 'moment'; | ||
import {format, getMonth, getYear} from 'date-fns'; | ||
import Str from 'expensify-common/lib/str'; | ||
import Navigation from '../../libs/Navigation/Navigation'; | ||
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; | ||
|
@@ -19,6 +19,7 @@ import CONST from '../../CONST'; | |
import FullPageOfflineBlockingView from '../../components/BlockingViews/FullPageOfflineBlockingView'; | ||
import {withNetwork} from '../../components/OnyxProvider'; | ||
import networkPropTypes from '../../components/networkPropTypes'; | ||
import DateUtils from '../../libs/DateUtils'; | ||
|
||
const propTypes = { | ||
/** The route object passed to this page from the navigator */ | ||
|
@@ -55,15 +56,15 @@ function WalletStatementPage(props) { | |
const yearMonth = lodashGet(props.route.params, 'yearMonth', null); | ||
|
||
useEffect(() => { | ||
const currentYearMonth = moment().format('YYYYMM'); | ||
const currentYearMonth = format(new Date(), CONST.DATE.YEAR_MONTH_FORMAT); | ||
if (!yearMonth || yearMonth.length !== 6 || yearMonth > currentYearMonth) { | ||
Navigation.dismissModal(); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps -- we want this effect to run only on mount | ||
}, []); | ||
|
||
useEffect(() => { | ||
moment.locale(props.preferredLocale); | ||
DateUtils.setLocale(props.preferredLocale); | ||
}, [props.preferredLocale]); | ||
|
||
const processDownload = () => { | ||
|
@@ -84,9 +85,9 @@ function WalletStatementPage(props) { | |
User.generateStatementPDF(yearMonth); | ||
}; | ||
|
||
const year = yearMonth.substring(0, 4) || moment().year(); | ||
const month = yearMonth.substring(4) || moment().month(); | ||
const monthName = moment(month, 'M').format('MMMM'); | ||
const year = yearMonth.substring(0, 4) || getYear(new Date()); | ||
const month = yearMonth.substring(4) || getMonth(new Date()); | ||
const monthName = format(new Date(year, month), CONST.DATE.MONTH_FORMAT); | ||
Comment on lines
+88
to
+90
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. 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. Probably new one is correct, I tried with new dates and moment is showing september for some reason, but date-fns October(which is correct) |
||
const title = `${monthName} ${year} statement`; | ||
const url = `${CONFIG.EXPENSIFY.EXPENSIFY_URL}statement.php?period=${yearMonth}`; | ||
|
||
|
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.
This is
yyyy-MM-dd
unlikeYYYY-MM-DD
as it was previously.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.
Yes, its the same, moment uses own formats, date-fns uses IANA and doesnt support YYYY-MM-DD
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.
Not sure about this comment, the output of the date here is same as from moment, right? @allroundexperts @waterim
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.
confirmed its the same in DM