Skip to content

Commit 5f68854

Browse files
时间显示为当前时区时间
1 parent 67b556c commit 5f68854

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
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 { dateStringUTC } from 'lib/DateUtils';
8+
import { dateStringLocale } 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 = dateStringUTC(value);
42+
content = dateStringLocale(value);
4343
} else if (type === 'Boolean') {
4444
content = value ? 'True' : 'False';
4545
} else if (type === 'Array') {

src/lib/DateUtils.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,24 @@ export function dateStringUTC(date) {
128128
return full;
129129
}
130130

131+
export function dateStringLocale(date) {
132+
let full = String(date.getDate()) + ' ' +
133+
shortMonth(date.getMonth()) + ' ' +
134+
String(date.getFullYear()) + ' at ';
135+
let time = {
136+
hours: String(date.getHours()),
137+
minutes: String(date.getMinutes()),
138+
seconds: String(date.getSeconds())
139+
};
140+
for (let k in time) {
141+
if (time[k].length < 2) {
142+
time[k] = '0' + time[k];
143+
}
144+
}
145+
full += time.hours + ':' + time.minutes + ':' + time.seconds;
146+
return full;
147+
}
148+
131149
export function monthDayStringUTC(date) {
132150
return `${shortMonth(date.getUTCMonth())} ${date.getUTCDate()}`;
133151
}

0 commit comments

Comments
 (0)