Skip to content

Commit 7df1dbb

Browse files
SaraVieiraMichaelDeBoey
authored andcommitted
remove moment (codesandbox#2315)
* remove momemt * fix dates * Update packages/app/src/app/pages/common/Modals/SelectSandboxModal/Sandbox/index.js Co-Authored-By: Michaël De Boey <[email protected]>
1 parent b7ad517 commit 7df1dbb

File tree

10 files changed

+24
-32
lines changed

10 files changed

+24
-32
lines changed

packages/app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@
207207
"mobx-react": "^6.1.1",
208208
"mobx-react-lite": "^1.4.1",
209209
"mobx-state-tree": "^3.14.0",
210-
"moment": "^2.18.1",
211210
"monaco-editor-textmate": "^2.0.0",
212211
"monaco-textmate": "^3.0.0",
213212
"monaco-vue": "^0.2.1",

packages/app/src/app/components/SandboxList/SandboxList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import moment from 'moment';
2+
import { format } from 'date-fns';
33
import { Link } from 'react-router-dom';
44
import FullHeartIcon from 'react-icons/lib/fa/heart';
55
import EyeIcon from 'react-icons/lib/fa/eye';
@@ -65,8 +65,8 @@ export const SandboxList: React.FC<ISandboxListProps> = ({
6565
<Link to={sandboxUrl(s)}>{s.title || s.id}</Link>
6666
<PrivacyStatus privacy={s.privacy} asIcon />
6767
</td>
68-
<td>{moment(s.insertedAt).format('ll')}</td>
69-
<td>{moment(s.updatedAt).format('ll')}</td>
68+
<td>{format(s.insertedAt, 'MMM DD, YYYY')}</td>
69+
<td>{format(s.updatedAt, 'MMM DD, YYYY')}</td>
7070
<StatBody>
7171
<Icon width={30} height={30} />
7272
</StatBody>

packages/app/src/app/pages/Dashboard/Content/SandboxGrid/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { inject, observer } from 'app/componentConnectors';
33

4-
import moment from 'moment';
4+
import { distanceInWordsToNow } from 'date-fns';
55
import { uniq } from 'lodash-es';
66
import { basename } from 'path';
77
import { camelizeKeys } from 'humps';
@@ -270,15 +270,15 @@ class SandboxGrid extends React.Component<*, State> {
270270

271271
const getOrder = () => {
272272
if (item.removedAt) {
273-
return `Deleted ${moment.utc(item.removedAt).fromNow()}`;
273+
return `Deleted ${distanceInWordsToNow(item.removedAt)} ago`;
274274
}
275275

276276
const orderField = this.props.store.dashboard.orderBy.field;
277277
if (orderField === 'insertedAt') {
278-
return `Created ${moment.utc(item.insertedAt).fromNow()}`;
278+
return `Created ${distanceInWordsToNow(item.insertedAt)} ago`;
279279
}
280280

281-
return `Edited ${moment.utc(item.updatedAt).fromNow()}`;
281+
return `Edited ${distanceInWordsToNow(item.updatedAt)} ago`;
282282
};
283283

284284
let editedSince = getOrder();
@@ -409,15 +409,15 @@ class SandboxGrid extends React.Component<*, State> {
409409
label="Last Updated"
410410
dataKey="updatedAt"
411411
cellDataGetter={({ rowData }) =>
412-
moment.utc(rowData.updatedAt).fromNow()
412+
distanceInWordsToNow(rowData.updatedAt) + ' ago'
413413
}
414414
width={150}
415415
/>
416416
<Column
417417
label="Created"
418418
dataKey="insertedAt"
419419
cellDataGetter={({ rowData }) =>
420-
moment.utc(rowData.insertedAt).fromNow()
420+
distanceInWordsToNow(rowData.insertedAt) + ' ago'
421421
}
422422
width={150}
423423
/>

packages/app/src/app/pages/Patron/PricingModal/PricingChoice/ChangeSubscription/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import { inject, hooksObserver } from 'app/componentConnectors';
3-
import moment from 'moment';
3+
import { format } from 'date-fns';
44
import { LinkButton } from 'app/components/LinkButton';
55

66
import { SmallText, Buttons, StyledButton, StripeInput } from './elements';
@@ -84,9 +84,9 @@ function ChangeSubscription({
8484
<div>
8585
{buttons}
8686
<SmallText>
87-
You will be billed every <strong>{moment(date).format('Do')}</strong> of
88-
the month, you can change or cancel your subscription at any time. You
89-
can change your payment method in{' '}
87+
You will be billed every <strong>{format(date, 'Do')}</strong> of the
88+
month, you can change or cancel your subscription at any time. You can
89+
change your payment method in{' '}
9090
<LinkButton
9191
onClick={e => {
9292
e.preventDefault();

packages/app/src/app/pages/Patron/PricingModal/PricingChoice/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import moment from 'moment';
2+
import { format } from 'date-fns';
33
import Centered from '@codesandbox/common/lib/components/flex/Centered';
44
import Relative from '@codesandbox/common/lib/components/Relative';
55
import badges from '@codesandbox/common/lib/utils/badges/patron-info';
@@ -91,7 +91,7 @@ const PricingChoice = inject('store', 'signals')(
9191
<Notice>
9292
You will be billed now and on the{' '}
9393
<strong style={{ color: 'white' }}>
94-
{moment().format('Do')}
94+
{format(new Date(), 'Do')}
9595
</strong>{' '}
9696
of each month thereafter. You can cancel or change your
9797
subscription at any time.

packages/app/src/app/pages/common/Modals/SelectSandboxModal/Sandbox/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import moment from 'moment';
2+
import { format } from 'date-fns';
33
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
44

55
import { Date, Button } from './elements';
@@ -17,7 +17,7 @@ export default class Sandbox extends React.PureComponent {
1717
{getSandboxName(sandbox)}
1818
{active && ' (Selected)'}
1919
</div>
20-
<Date>{moment(sandbox.insertedAt).format('ll')}</Date>
20+
<Date>{format(sandbox.insertedAt, 'MMM DD, YYYY')}</Date>
2121
</Button>
2222
);
2323
}

packages/app/src/app/pages/common/Modals/StorageManagementModal/FilesList/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { Component } from 'react';
2-
import moment from 'moment';
32
import { sortBy, isEmpty } from 'lodash-es';
43
import filesize from 'filesize';
54
import { Button } from '@codesandbox/common/lib/components/Button';
@@ -71,10 +70,10 @@ class FilesList extends Component {
7170
`}
7271
/>
7372
<HeaderTitle>File</HeaderTitle>
74-
<HeaderTitle>Created</HeaderTitle>
7573
<HeaderTitle>Size</HeaderTitle>
7674
<HeaderTitle />
7775
<HeaderTitle />
76+
<HeaderTitle />
7877
</tr>
7978
</thead>
8079
<Body>
@@ -100,8 +99,6 @@ class FilesList extends Component {
10099
{f.name}
101100
</a>
102101
</td>
103-
104-
<td>{moment(f.insertedAt).format('ll')}</td>
105102
<td>{filesize(f.objectSize)}</td>
106103
<StatBody
107104
css={`

packages/common/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
},
2424
"dependencies": {
2525
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
26-
"@sentry/browser": "^5.6.2",
2726
"@babel/polyfill": "^7.4.4",
2827
"@codesandbox/notifications": "^1.0.3",
2928
"@codesandbox/template-icons": "^0.7.0",
29+
"@sentry/browser": "^5.6.2",
3030
"@tippy.js/react": "^2.1.1",
3131
"babel-plugin-preval": "^3.0.1",
3232
"codesandbox-api": "^0.0.22",
@@ -39,7 +39,6 @@
3939
"lodash": "^4.17.11",
4040
"markty-toml": "^0.0.9",
4141
"memoize-one": "^3.1.1",
42-
"moment": "^2.18.1",
4342
"ot": "^0.0.15",
4443
"react": "^16.8.6",
4544
"react-icons": "^2.2.7",

packages/common/src/components/PatronStar/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import moment from 'moment';
2+
import { format } from 'date-fns';
33
import StarIcon from 'react-icons/lib/go/star';
44
import Tooltip from '../Tooltip';
55

@@ -12,9 +12,7 @@ interface PatronStarProps {
1212

1313
export function PatronStar({ subscriptionSince, ...props }: PatronStarProps) {
1414
return (
15-
<Tooltip
16-
content={`Patron since ${moment(subscriptionSince).format('MMM Y')}`}
17-
>
15+
<Tooltip content={`Patron since ${format(subscriptionSince, 'MMM Y')}`}>
1816
<Container>
1917
<StarIcon {...props} />
2018
</Container>

yarn.lock

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15893,10 +15893,9 @@ modularscale@^1.0.2:
1589315893
dependencies:
1589415894
lodash.isnumber "^3.0.0"
1589515895

15896-
moment@^2.18.1, moment@^2.21.0, moment@^2.6.0:
15897-
version "2.24.0"
15898-
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
15899-
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
15896+
moment@^2.21.0, moment@^2.6.0:
15897+
version "2.22.2"
15898+
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
1590015899

1590115900
monaco-editor-textmate@^2.0.0:
1590215901
version "2.0.0"

0 commit comments

Comments
 (0)