Skip to content

Commit

Permalink
fix: 修复daterange识别日期错误问题 (baidu#10288)
Browse files Browse the repository at this point in the history
Co-authored-by: qinhaoyan <[email protected]>
  • Loading branch information
qkiroc and qkiroc authored May 22, 2024
1 parent 9c28e2e commit 6b148a1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/amis/src/renderers/DateRange.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}>
Expand Down

0 comments on commit 6b148a1

Please sign in to comment.