mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:29:24 +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 {Renderer, RendererProps} from 'amis-core';
|
||||
import {Renderer, RendererProps, normalizeDate} from 'amis-core';
|
||||
import moment from 'moment';
|
||||
import {BaseSchema} from '../Schema';
|
||||
import {getPropValue} from 'amis-core';
|
||||
@ -78,17 +78,17 @@ export class DateRangeField extends React.Component<DateRangeProps, Object> {
|
||||
let [startTime = '', endTime = ''] = value;
|
||||
|
||||
if (valueFormat) {
|
||||
startTime = moment(startTime, valueFormat);
|
||||
endTime = moment(endTime, valueFormat);
|
||||
startTime = normalizeDate(startTime, valueFormat);
|
||||
endTime = normalizeDate(endTime, valueFormat);
|
||||
} else {
|
||||
startTime = moment(startTime * 1000);
|
||||
endTime = moment(endTime * 1000);
|
||||
startTime = normalizeDate(startTime * 1000);
|
||||
endTime = normalizeDate(endTime * 1000);
|
||||
}
|
||||
|
||||
startTime = startTime.isValid()
|
||||
startTime = startTime?.isValid()
|
||||
? startTime.format(displayFormat || format)
|
||||
: '';
|
||||
endTime = endTime.isValid() ? endTime.format(displayFormat || format) : '';
|
||||
endTime = endTime?.isValid() ? endTime.format(displayFormat || format) : '';
|
||||
|
||||
return (
|
||||
<span className={cx('DateRangeField', className)} style={style}>
|
||||
|
Loading…
Reference in New Issue
Block a user