aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/hidden.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hidden.js')
-rw-r--r--examples/hidden.js30
1 files changed, 13 insertions, 17 deletions
diff --git a/examples/hidden.js b/examples/hidden.js
index 16abd2a..90a20d2 100644
--- a/examples/hidden.js
+++ b/examples/hidden.js
@@ -5,32 +5,28 @@ 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);
18
19const now = new GregorianCalendar(TimePickerLocale.calendar);
20now.setTime(Date.now());
21
22function onChange(value) { 15function onChange(value) {
23 console.log(value && formatter.format(value)); 16 console.log(value && value.format(str));
24} 17}
25 18
26ReactDom.render( 19ReactDom.render(
27 <TimePicker formatter={formatter} locale={TimePickerLocale} 20 <TimePicker
28 showSecond={showSecond} 21 format={str}
29 defaultValue={now} 22 showSecond={showSecond}
30 className="xxx" 23 // use to control utfOffset, locale, default open value
31 onChange={onChange} 24 defaultOpenValue={moment()}
32 disabledHours={() => [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} 25 className="xxx"
33 disabledMinutes={() => [0, 2, 4, 6, 8]} 26 onChange={onChange}
34 hideDisabledOptions />, 27 disabledHours={() => [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]}
28 disabledMinutes={() => [0, 2, 4, 6, 8]}
29 hideDisabledOptions
30 />,
35 document.getElementById('__react-content') 31 document.getElementById('__react-content')
36); 32);