---
+1.1.0 / 2016-01-14
+---------------------------
+
+remove gregorianCalendarLocale prop, move to locale.calendar
+
1.0.0 / 2015-12-21
-------------------------
| open | Boolean | false | current open state of picker. controlled prop |
| defaultValue | GregorianCalendar | null | default initial value |
| value | GregorianCalendar | null | current value |
-| gregorianCalendarLocale | GregorianCalendar locale object | null | if value and defaultValue not set, you should set this to your locale |
| placeholder | String | '' | time input's placeholder |
| showHour | Boolean | whether show hour | |
| showSecond | Boolean | whether show second | |
import GregorianCalendar from 'gregorian-calendar';
import DateTimeFormat from 'gregorian-calendar-format';
-import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
import TimePicker from 'rc-time-picker';
import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
const formatter = new DateTimeFormat(str);
-const now = new GregorianCalendar(zhCn);
+const now = new GregorianCalendar(TimePickerLocale.calendar);
now.setTime(Date.now());
function generateOptions(length, excludedOptions) {
import GregorianCalendar from 'gregorian-calendar';
import DateTimeFormat from 'gregorian-calendar-format';
-import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
import TimePicker from 'rc-time-picker';
import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
const formatter = new DateTimeFormat(str);
-const now = new GregorianCalendar(zhCn);
+const now = new GregorianCalendar(TimePickerLocale.calendar);
now.setTime(Date.now());
function onChange(value) {
import GregorianCalendar from 'gregorian-calendar';
import DateTimeFormat from 'gregorian-calendar-format';
-import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
import TimePicker from 'rc-time-picker';
import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
const formatter = new DateTimeFormat(str);
-const now = new GregorianCalendar(zhCn);
+const now = new GregorianCalendar(TimePickerLocale.calendar);
now.setTime(Date.now());
function onChange(value) {
import GregorianCalendar from 'gregorian-calendar';
import DateTimeFormat from 'gregorian-calendar-format';
-import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
-
import TimePicker from 'rc-time-picker';
import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
const formatter = new DateTimeFormat('HH:mm:ss');
-const now = new GregorianCalendar(zhCn);
+const now = new GregorianCalendar(TimePickerLocale.calendar);
now.setTime(Date.now());
const App = React.createClass({
console.log(value && formatter.format(value));
this.setState({ value });
},
+ clear() {
+ this.setState({
+ value: undefined,
+ });
+ },
render() {
return (
<div>
<TimePicker formatter={formatter} locale={TimePickerLocale}
value={this.state.value}
onChange={this.handleValueChange}/>
+ <button onClick={this.clear}>clear</button>
</div>
);
},
{
"name": "rc-time-picker",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "React TimePicker",
"keywords": [
"react",
import placements from './util/placements';
import CommonMixin from './mixin/CommonMixin';
import {getFormatter} from './util/index';
-import defaultGregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US';
function noop() {
}
placement: PropTypes.any,
transitionName: PropTypes.string,
getPopupContainer: PropTypes.func,
- gregorianCalendarLocale: PropTypes.object,
placeholder: PropTypes.string,
formatter: PropTypes.any,
showHour: PropTypes.bool,
defaultOpen: false,
style: {},
className: '',
- gregorianCalendarLocale: defaultGregorianCalendarLocale,
align: {},
allowEmpty: true,
showHour: true,
componentWillReceiveProps(nextProps) {
const { value, open } = nextProps;
- if (value !== undefined) {
+ if ('value' in nextProps) {
this.setState({
value,
});
},
getPanelElement() {
- const { prefixCls, defaultValue, locale, placeholder, disabledHours, disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, gregorianCalendarLocale, value } = this.props;
- let calendarLocale;
- if (value) {
- calendarLocale = value.locale;
- } else if (defaultValue) {
- calendarLocale = defaultValue.locale;
- } else {
- calendarLocale = gregorianCalendarLocale;
- }
+ const { prefixCls, defaultValue, locale, placeholder, disabledHours,
+ disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond } = this.props;
return (
<Panel
prefixCls={`${prefixCls}-panel`}
ref={this.savePanelRef}
value={this.state.value}
onChange={this.onPanelChange}
- gregorianCalendarLocale={calendarLocale}
+ gregorianCalendarLocale={locale.calendar}
onClear={this.onPanelClear}
defaultValue={defaultValue}
showHour={showHour}
import enUs from 'gregorian-calendar-format/lib/locale/en_US';
+import enUsCalendar from 'gregorian-calendar/lib/locale/en_US';
export default {
clear: 'Clear',
format: enUs,
+ calendar: enUsCalendar,
};
import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN';
+import zhCnCalendar from 'gregorian-calendar/lib/locale/zh_CN';
export default {
clear: '清除',
format: zhCn,
+ calendar: zhCnCalendar,
};