Skip to content

Commit 3c4fcfa

Browse files
日志也显示本地时间
1 parent d713f3b commit 3c4fcfa

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

src/components/BrowserCell/BrowserCell.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8-
import { dateStringLocale } from 'lib/DateUtils';
8+
import { dateStringUTC } from 'lib/DateUtils';
99
import getFileName from 'lib/getFileName';
1010
import Parse from 'parse';
1111
import Pill from 'components/Pill/Pill.react';
@@ -39,7 +39,7 @@ let BrowserCell = ({ type, value, hidden, width, current, onSelect, onEditChange
3939
</a>
4040
);
4141
} else if (type === 'Date') {
42-
content = dateStringLocale(value);
42+
content = dateStringUTC(value);
4343
} else if (type === 'Boolean') {
4444
content = value ? 'True' : 'False';
4545
} else if (type === 'Array') {

src/components/LogView/LogViewEntry.react.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import PropTypes from 'lib/PropTypes';
99
import React from 'react';
1010
import styles from 'components/LogView/LogViewEntry.scss';
11+
import { dateStringUTC } from 'lib/DateUtils';
1112

1213
const TIMESTAMP_REGEX = [
1314
'([a-z])', // Any Single Word Character (Not Whitespace) 1
@@ -41,10 +42,12 @@ let LogViewEntry = ({
4142
}) => {
4243
let logEntryInfo = getLogEntryInfo(text);
4344
let classes = [styles.entry, logEntryInfo.error ? styles.error: ''];
45+
let oldDate=new Date(timestamp)
46+
let newDate=dateStringUTC(oldDate)
4447
return (
4548
<li className={classes.join(' ')}>
4649
{/* handle the timestamp format used by both Parse Server and Parse.com */}
47-
<span className={styles.time}>{timestamp.iso || timestamp} - </span>
50+
<span className={styles.time}>{newDate} - </span>
4851
<span className={styles.content}>{logEntryInfo.content}</span>
4952
</li>
5053
);

src/lib/DateUtils.js

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,21 @@ export function monthsFrom(date, delta) {
111111
}
112112

113113
export function dateStringUTC(date) {
114-
let full = String(date.getUTCDate()) + ' ' +
115-
shortMonth(date.getUTCMonth()) + ' ' +
116-
String(date.getUTCFullYear()) + ' at ';
117-
let time = {
118-
hours: String(date.getUTCHours()),
119-
minutes: String(date.getUTCMinutes()),
120-
seconds: String(date.getUTCSeconds())
121-
};
122-
for (let k in time) {
123-
if (time[k].length < 2) {
124-
time[k] = '0' + time[k];
125-
}
126-
}
127-
full += time.hours + ':' + time.minutes + ':' + time.seconds + ' UTC';
128-
return full;
129-
}
130-
131-
export function dateStringLocale(date) {
114+
// let full = String(date.getUTCDate()) + ' ' +
115+
// shortMonth(date.getUTCMonth()) + ' ' +
116+
// String(date.getUTCFullYear()) + ' at ';
117+
// let time = {
118+
// hours: String(date.getUTCHours()),
119+
// minutes: String(date.getUTCMinutes()),
120+
// seconds: String(date.getUTCSeconds())
121+
// };
122+
// for (let k in time) {
123+
// if (time[k].length < 2) {
124+
// time[k] = '0' + time[k];
125+
// }
126+
// }
127+
// full += time.hours + ':' + time.minutes + ':' + time.seconds + ' UTC';
128+
// return full;
132129
let month=date.getMonth()+1
133130
let date2=date.getDate()
134131
if(month<10){
@@ -137,9 +134,6 @@ export function dateStringLocale(date) {
137134
if(date2<10){
138135
date2 = "0" + date2;
139136
}
140-
// let full = String(date.getDate()) + ' ' +
141-
// shortMonth(date.getMonth()) + ' ' +
142-
// String(date.getFullYear()) + ' at ';
143137
let full=String(String(date.getFullYear()+'-'+month+'-'+date2 +' '))
144138
let time = {
145139
hours: String(date.getHours()),
@@ -155,6 +149,33 @@ export function dateStringLocale(date) {
155149
return full;
156150
}
157151

152+
// export function dateStringLocale(date) {
153+
// let month=date.getMonth()+1
154+
// let date2=date.getDate()
155+
// if(month<10){
156+
// month = "0" + month;
157+
// }
158+
// if(date2<10){
159+
// date2 = "0" + date2;
160+
// }
161+
// // let full = String(date.getDate()) + ' ' +
162+
// // shortMonth(date.getMonth()) + ' ' +
163+
// // String(date.getFullYear()) + ' at ';
164+
// let full=String(String(date.getFullYear()+'-'+month+'-'+date2 +' '))
165+
// let time = {
166+
// hours: String(date.getHours()),
167+
// minutes: String(date.getMinutes()),
168+
// seconds: String(date.getSeconds())
169+
// };
170+
// for (let k in time) {
171+
// if (time[k].length < 2) {
172+
// time[k] = '0' + time[k];
173+
// }
174+
// }
175+
// full += time.hours + ':' + time.minutes + ':' + time.seconds;
176+
// return full;
177+
// }
178+
158179
export function monthDayStringUTC(date) {
159180
return `${shortMonth(date.getUTCMonth())} ${date.getUTCDate()}`;
160181
}

0 commit comments

Comments
 (0)