mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:48:32 +08:00
fix: 修复daterange识别日期错误问题 (#10288)
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
parent
9c28e2e842
commit
6b148a1773
@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {Renderer, RendererProps} from 'amis-core';
|
import {Renderer, RendererProps, normalizeDate} from 'amis-core';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {BaseSchema} from '../Schema';
|
import {BaseSchema} from '../Schema';
|
||||||
import {getPropValue} from 'amis-core';
|
import {getPropValue} from 'amis-core';
|
||||||
@ -78,17 +78,17 @@ export class DateRangeField extends React.Component<DateRangeProps, Object> {
|
|||||||
let [startTime = '', endTime = ''] = value;
|
let [startTime = '', endTime = ''] = value;
|
||||||
|
|
||||||
if (valueFormat) {
|
if (valueFormat) {
|
||||||
startTime = moment(startTime, valueFormat);
|
startTime = normalizeDate(startTime, valueFormat);
|
||||||
endTime = moment(endTime, valueFormat);
|
endTime = normalizeDate(endTime, valueFormat);
|
||||||
} else {
|
} else {
|
||||||
startTime = moment(startTime * 1000);
|
startTime = normalizeDate(startTime * 1000);
|
||||||
endTime = moment(endTime * 1000);
|
endTime = normalizeDate(endTime * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = startTime.isValid()
|
startTime = startTime?.isValid()
|
||||||
? startTime.format(displayFormat || format)
|
? startTime.format(displayFormat || format)
|
||||||
: '';
|
: '';
|
||||||
endTime = endTime.isValid() ? endTime.format(displayFormat || format) : '';
|
endTime = endTime?.isValid() ? endTime.format(displayFormat || format) : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={cx('DateRangeField', className)} style={style}>
|
<span className={cx('DateRangeField', className)} style={style}>
|
||||||
|
Loading…
Reference in New Issue
Block a user