Skip to content

Commit

Permalink
Merge pull request #720 from XiaoMi/hotfix/1.5.8-datepicker
Browse files Browse the repository at this point in the history
fix:1970
  • Loading branch information
solarjoker authored Oct 14, 2019
2 parents f172b8b + 2266342 commit 82aabc0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions components/date-picker/BasePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BasePicker extends Component {
*/
if (value === '' || !value) {
// value 未传入情况
date = null
date = new Date()
noText = true
}
if (typeof value === 'number' || (typeof value === 'string' && value.trim().length > 4)) {
Expand All @@ -109,12 +109,16 @@ class BasePicker extends Component {
}

if (type.includes('range') || type === 'timeperiod') {
if (value instanceof Date) {
// 如果为时间段选择,则取默认的第一个范围
date = {startDate: startOfDay(date), endDate: type === 'timeperiod' ? addHours(startOfDay(date), 4) : endOfDay(date)}
}
if (value && value.start && value.end) {
date = {startDate: value.start, endDate: value.end}
if (value) {
if (value instanceof Date) {
// 如果为时间段选择,则取默认的第一个范围
date = {startDate: startOfDay(date), endDate: type === 'timeperiod' ? addHours(startOfDay(date), 4) : endOfDay(date)}
}
if (value.start && value.end) {
date = {startDate: value.start, endDate: value.end}
}
} else {
date = {startDate: new Date(), endDate: new Date()}
}
}
const leftText = noText ? '' : formatterDate(type, date.startDate || date, format, showTime, localeDatas, weekOffset)
Expand Down
1 change: 1 addition & 0 deletions components/date-picker/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ $basic-color: #4284f5 !default;

p {
cursor: pointer;
margin: 14px 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hi-ui/hiui",
"version": "1.5.8",
"version": "1.5.9",
"description": "HIUI for React",
"scripts": {
"test": "node_modules/.bin/standard && node_modules/.bin/stylelint --config .stylelintrc 'components/**/*.scss'",
Expand Down

0 comments on commit 82aabc0

Please sign in to comment.