Skip to content

Commit 0f381df

Browse files
committed
Revert "remove moment (codesandbox#2315)"
This reverts commit 7df1dbb.
1 parent 5bfc121 commit 0f381df

File tree

10 files changed

+32
-24
lines changed

10 files changed

+32
-24
lines changed

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
"mobx-react": "^6.1.1",
209209
"mobx-react-lite": "^1.4.1",
210210
"mobx-state-tree": "^3.14.0",
211+
"moment": "^2.18.1",
211212
"monaco-editor-textmate": "^2.0.0",
212213
"monaco-textmate": "^3.0.0",
213214
"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 { format } from 'date-fns';
2+
import moment from 'moment';
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>{format(s.insertedAt, 'MMM DD, YYYY')}</td>
69-
<td>{format(s.updatedAt, 'MMM DD, YYYY')}</td>
68+
<td>{moment(s.insertedAt).format('ll')}</td>
69+
<td>{moment(s.updatedAt).format('ll')}</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 { distanceInWordsToNow } from 'date-fns';
4+
import moment from 'moment';
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 ${distanceInWordsToNow(item.removedAt)} ago`;
273+
return `Deleted ${moment.utc(item.removedAt).fromNow()}`;
274274
}
275275

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

281-
return `Edited ${distanceInWordsToNow(item.updatedAt)} ago`;
281+
return `Edited ${moment.utc(item.updatedAt).fromNow()}`;
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-
distanceInWordsToNow(rowData.updatedAt) + ' ago'
412+
moment.utc(rowData.updatedAt).fromNow()
413413
}
414414
width={150}
415415
/>
416416
<Column
417417
label="Created"
418418
dataKey="insertedAt"
419419
cellDataGetter={({ rowData }) =>
420-
distanceInWordsToNow(rowData.insertedAt) + ' ago'
420+
moment.utc(rowData.insertedAt).fromNow()
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 { format } from 'date-fns';
3+
import moment from 'moment';
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>{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{' '}
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{' '}
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 { format } from 'date-fns';
2+
import moment from 'moment';
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-
{format(new Date(), 'Do')}
94+
{moment().format('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 { format } from 'date-fns';
2+
import moment from 'moment';
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>{format(sandbox.insertedAt, 'MMM DD, YYYY')}</Date>
20+
<Date>{moment(sandbox.insertedAt).format('ll')}</Date>
2121
</Button>
2222
);
2323
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component } from 'react';
2+
import moment from 'moment';
23
import { sortBy, isEmpty } from 'lodash-es';
34
import filesize from 'filesize';
45
import { Button } from '@codesandbox/common/lib/components/Button';
@@ -70,10 +71,10 @@ class FilesList extends Component {
7071
`}
7172
/>
7273
<HeaderTitle>File</HeaderTitle>
74+
<HeaderTitle>Created</HeaderTitle>
7375
<HeaderTitle>Size</HeaderTitle>
7476
<HeaderTitle />
7577
<HeaderTitle />
76-
<HeaderTitle />
7778
</tr>
7879
</thead>
7980
<Body>
@@ -99,6 +100,8 @@ class FilesList extends Component {
99100
{f.name}
100101
</a>
101102
</td>
103+
104+
<td>{moment(f.insertedAt).format('ll')}</td>
102105
<td>{filesize(f.objectSize)}</td>
103106
<StatBody
104107
css={`

packages/common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
},
2525
"dependencies": {
2626
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
27+
"@sentry/browser": "^5.6.2",
2728
"@babel/polyfill": "^7.4.4",
2829
"@codesandbox/notifications": "^1.0.3",
2930
"@codesandbox/template-icons": "^0.7.0",
30-
"@sentry/browser": "^5.6.2",
3131
"@tippy.js/react": "^2.1.1",
3232
"babel-plugin-preval": "^3.0.1",
3333
"codesandbox-api": "^0.0.22",
@@ -41,6 +41,7 @@
4141
"lodash": "^4.17.11",
4242
"markty-toml": "^0.0.9",
4343
"memoize-one": "^3.1.1",
44+
"moment": "^2.18.1",
4445
"ot": "^0.0.15",
4546
"react": "^16.8.6",
4647
"react-icons": "^2.2.7",

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

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

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

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

yarn.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15898,9 +15898,10 @@ modularscale@^1.0.2:
1589815898
dependencies:
1589915899
lodash.isnumber "^3.0.0"
1590015900

15901-
moment@^2.21.0, moment@^2.6.0:
15902-
version "2.22.2"
15903-
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"
15901+
moment@^2.18.1, moment@^2.21.0, moment@^2.6.0:
15902+
version "2.24.0"
15903+
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
15904+
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
1590415905

1590515906
monaco-editor-textmate@^2.0.0:
1590615907
version "2.0.0"

0 commit comments

Comments
 (0)