aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/disabled.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/disabled.js')
-rw-r--r--examples/disabled.js28
1 files changed, 12 insertions, 16 deletions
diff --git a/examples/disabled.js b/examples/disabled.js
index b650448..9d74002 100644
--- a/examples/disabled.js
+++ b/examples/disabled.js
@@ -5,19 +5,14 @@ import 'rc-time-picker/assets/index.less';
5import React from 'react'; 5import React from 'react';
6import ReactDom from 'react-dom'; 6import ReactDom from 'react-dom';
7 7
8import GregorianCalendar from 'gregorian-calendar'; 8import moment from 'moment';
9import DateTimeFormat from 'gregorian-calendar-format';
10 9
11import TimePicker from 'rc-time-picker'; 10import TimePicker from 'rc-time-picker';
12import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
13 11
14const showSecond = true; 12const showSecond = true;
15const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; 13const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
16 14
17const formatter = new DateTimeFormat(str); 15const now = moment().hour(14).minute(30);
18
19const now = new GregorianCalendar(TimePickerLocale.calendar);
20now.setTime(Date.now());
21 16
22function generateOptions(length, excludedOptions) { 17function generateOptions(length, excludedOptions) {
23 const arr = []; 18 const arr = [];
@@ -30,7 +25,7 @@ function generateOptions(length, excludedOptions) {
30} 25}
31 26
32function onChange(value) { 27function onChange(value) {
33 console.log(value && formatter.format(value)); 28 console.log(value && value.format(str));
34} 29}
35 30
36function disabledHours() { 31function disabledHours() {
@@ -53,13 +48,14 @@ function disabledSeconds(h, m) {
53} 48}
54 49
55ReactDom.render( 50ReactDom.render(
56 <TimePicker formatter={formatter} locale={TimePickerLocale} 51 <TimePicker
57 showSecond={showSecond} 52 showSecond={showSecond}
58 defaultValue={now} 53 defaultValue={now}
59 className="xxx" 54 className="xxx"
60 onChange={onChange} 55 onChange={onChange}
61 disabledHours={disabledHours} 56 disabledHours={disabledHours}
62 disabledMinutes={disabledMinutes} 57 disabledMinutes={disabledMinutes}
63 disabledSeconds={disabledSeconds}/>, 58 disabledSeconds={disabledSeconds}
59 />,
64 document.getElementById('__react-content') 60 document.getElementById('__react-content')
65); 61);