diff --git a/components/date-picker/demo/time.md b/components/date-picker/demo/time.md index 88eabea919..387d589140 100644 --- a/components/date-picker/demo/time.md +++ b/components/date-picker/demo/time.md @@ -3,7 +3,7 @@ order: 4 title: 日期时间选择 --- -增加选择时间功能。不要修改时间的格式 `HH:mm:ss`。 +增加选择时间功能,当 `showTime` 为一个对象时,其属性会传递给内建的 `TimePicker`。 ````jsx import { DatePicker } from 'antd'; diff --git a/components/date-picker/index.md b/components/date-picker/index.md index ed131d744f..23ecf15ad0 100644 --- a/components/date-picker/index.md +++ b/components/date-picker/index.md @@ -34,9 +34,9 @@ english: DatePicker | popupStyle | 格外的弹出日历样式 | object | {} | | size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string | 无 | | locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) | -| showTime | 增加时间选择功能 | bool | false | | onOk | 点击确定按钮的回调 | function(Date value) | 无 | | getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 | +| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) | ### MonthPicker @@ -61,6 +61,7 @@ english: DatePicker | defaultValue | 默认日期 | [string/Date, string/Date] | 无 | | format | 展示的日期格式 | string | "yyyy-MM-dd HH:mm:ss" | | onChange | 时间发生变化的回调,发生在用户选择时间时 | function(date[], dateString[]) | 无 | +| showTime | 增加时间选择功能 | Object or Boolean | [TimePicker Options](http://ant.design/components/time-picker/#api) | `disabled` `style` `popupStyle` `size` `locale` `showTime` `onOk` `getCalendarContainer` 属性与 DatePicker 的一致。 diff --git a/components/date-picker/wrapPicker.jsx b/components/date-picker/wrapPicker.jsx index 3b1e1cd8df..b53d802237 100644 --- a/components/date-picker/wrapPicker.jsx +++ b/components/date-picker/wrapPicker.jsx @@ -94,12 +94,22 @@ export default function wrapPicker(Picker, defaultFormat) { }); const locale = this.getLocale(); + + const timeFormat = props.showTime && props.showTime.format; + const rcTimePickerProps = { + formatter: new DateTimeFormat(timeFormat || 'HH:mm:ss'), + showSecond: timeFormat && timeFormat.indexOf('ss') >= 0, + showHour: timeFormat && timeFormat.indexOf('HH') >= 0 + }; const timePicker = props.showTime ? ( + transitionName="slide-up" + /> ) : null; return (