Skip to content

Commit 8b4f554

Browse files
committed
fix: use moment to handle date
1 parent 0b1b079 commit 8b4f554

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

package-lock.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"history": "5.0.1",
5353
"html-react-parser": "^1.3.0",
5454
"lodash": "^4.17.21",
55+
"moment": "^2.29.3",
5556
"prop-types": "15.7.2",
5657
"query-string": "7.0.1",
5758
"react": "^16.14.0",

src/containers/ListView/SubmissionsTable.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
4+
import moment from 'moment';
45

56
import {
67
DataTable,
@@ -53,7 +54,7 @@ export class SubmissionsTable extends React.Component {
5354
}
5455

5556
formatDate = ({ value }) => {
56-
const date = new Date(value);
57+
const date = new Date(moment(value));
5758
return date.toLocaleString();
5859
}
5960

src/containers/ListView/SubmissionsTable.test.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ let el;
4343
jest.useFakeTimers('modern');
4444

4545
const dates = [
46-
new Date(16131215154955).toLocaleTimeString(),
47-
new Date(16131225154955).toLocaleTimeString(),
48-
new Date(16131215250955).toLocaleTimeString(),
46+
'2021-12-08 09:06:15.319213+00:00',
47+
'2021-12-10 18:06:15.319213+00:00',
48+
'2021-12-11 07:06:15.319213+00:00',
4949
];
5050

5151
const individualData = [

src/containers/ListView/__snapshots__/SubmissionsTable.test.jsx.snap

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
5858
data={
5959
Array [
6060
Object {
61-
"dateSubmitted": "9:05:54 PM",
61+
"dateSubmitted": "2021-12-08 09:06:15.319213+00:00",
6262
"gradingStatus": "ungraded",
6363
"score": Object {
6464
"pointsEarned": 1,
@@ -67,7 +67,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
6767
"username": "username-1",
6868
},
6969
Object {
70-
"dateSubmitted": "11:52:34 PM",
70+
"dateSubmitted": "2021-12-10 18:06:15.319213+00:00",
7171
"gradingStatus": "graded",
7272
"score": Object {
7373
"pointsEarned": 2,
@@ -76,7 +76,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: h
7676
"username": "username-2",
7777
},
7878
Object {
79-
"dateSubmitted": "9:07:30 PM",
79+
"dateSubmitted": "2021-12-11 07:06:15.319213+00:00",
8080
"gradingStatus": "in-progress",
8181
"score": Object {
8282
"pointsEarned": 3,
@@ -176,7 +176,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
176176
data={
177177
Array [
178178
Object {
179-
"dateSubmitted": "9:05:54 PM",
179+
"dateSubmitted": "2021-12-08 09:06:15.319213+00:00",
180180
"gradingStatus": "ungraded",
181181
"score": Object {
182182
"pointsEarned": 1,
@@ -185,7 +185,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
185185
"teamName": "teamName-1",
186186
},
187187
Object {
188-
"dateSubmitted": "11:52:34 PM",
188+
"dateSubmitted": "2021-12-10 18:06:15.319213+00:00",
189189
"gradingStatus": "graded",
190190
"score": Object {
191191
"pointsEarned": 2,
@@ -194,7 +194,7 @@ exports[`SubmissionsTable component component render tests snapshots snapshot: t
194194
"teamName": "teamName-2",
195195
},
196196
Object {
197-
"dateSubmitted": "9:07:30 PM",
197+
"dateSubmitted": "2021-12-11 07:06:15.319213+00:00",
198198
"gradingStatus": "in-progress",
199199
"score": Object {
200200
"pointsEarned": 3,

0 commit comments

Comments
 (0)