]>
Commit | Line | Data |
---|---|---|
e9060dda | 1 | /* eslint no-console:0 */ |
2 | ||
78637ac0 | 3 | import 'rc-time-picker/assets/index.less'; |
02de449a | 4 | |
5 | import React from 'react'; | |
6 | import ReactDom from 'react-dom'; | |
02de449a | 7 | |
78637ac0 | 8 | import GregorianCalendar from 'gregorian-calendar'; |
02de449a | 9 | import DateTimeFormat from 'gregorian-calendar-format'; |
78637ac0 M |
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; |
11 | ||
63541ed7 | 12 | import TimePicker from 'rc-time-picker'; |
78637ac0 | 13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; |
02de449a | 14 | |
e9060dda | 15 | const showSecond = true; |
16 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | |
8133e8cf | 17 | |
18 | const formatter = new DateTimeFormat(str); | |
02de449a | 19 | |
20 | const now = new GregorianCalendar(zhCn); | |
21 | now.setTime(Date.now()); | |
22 | ||
7702bb67 M |
23 | function onChange(value) { |
24 | console.log(value && formatter.format(value)); | |
9f9f39e4 | 25 | } |
26 | ||
518b852e M |
27 | const options = { |
28 | disabledHours() { | |
29 | return [0, 2, 21]; | |
30 | }, | |
31 | disabledMinutes(h) { | |
32 | return h === 22 ? [0, 3, 31] : []; | |
33 | }, | |
34 | disabledSeconds(h, m) { | |
35 | return []; | |
36 | }, | |
37 | }; | |
38 | ||
02de449a | 39 | ReactDom.render( |
8133e8cf | 40 | <TimePicker formatter={formatter} locale={TimePickerLocale} |
41 | showSecond={showSecond} | |
42 | defaultValue={now} | |
96d366af | 43 | className="xxx" |
518b852e M |
44 | onChange={onChange} |
45 | disabledHours={[0, 2, 21]} | |
46 | disabledMinutes={[0, 2, 21]} | |
47 | disabledSeconds={[]} | |
48 | hideDisabledOptions={true} />, | |
78637ac0 | 49 | document.getElementById('__react-content') |
02de449a | 50 | ); |