diff options
author | yiminghe <yiminghe@gmail.com> | 2016-08-04 19:53:55 +0800 |
---|---|---|
committer | yiminghe <yiminghe@gmail.com> | 2016-08-04 19:53:55 +0800 |
commit | 4984ed85e54f442998a335db70618d6184fa397e (patch) | |
tree | 6ae348b2cac5f48f3afb6f7b8dd0c2fd02f044fc /examples/hidden.js | |
parent | deaa6062ea2e274d50d58c70251c1237c0c03c67 (diff) | |
download | time-picker-4984ed85e54f442998a335db70618d6184fa397e.tar.gz time-picker-4984ed85e54f442998a335db70618d6184fa397e.tar.zst time-picker-4984ed85e54f442998a335db70618d6184fa397e.zip |
2.x :boom:2.0.0
Diffstat (limited to 'examples/hidden.js')
-rw-r--r-- | examples/hidden.js | 30 |
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'; | |||
5 | import React from 'react'; | 5 | import React from 'react'; |
6 | import ReactDom from 'react-dom'; | 6 | import ReactDom from 'react-dom'; |
7 | 7 | ||
8 | import GregorianCalendar from 'gregorian-calendar'; | 8 | import moment from 'moment'; |
9 | import DateTimeFormat from 'gregorian-calendar-format'; | ||
10 | 9 | ||
11 | import TimePicker from 'rc-time-picker'; | 10 | import TimePicker from 'rc-time-picker'; |
12 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | ||
13 | 11 | ||
14 | const showSecond = true; | 12 | const showSecond = true; |
15 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | 13 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; |
16 | 14 | ||
17 | const formatter = new DateTimeFormat(str); | ||
18 | |||
19 | const now = new GregorianCalendar(TimePickerLocale.calendar); | ||
20 | now.setTime(Date.now()); | ||
21 | |||
22 | function onChange(value) { | 15 | function onChange(value) { |
23 | console.log(value && formatter.format(value)); | 16 | console.log(value && value.format(str)); |
24 | } | 17 | } |
25 | 18 | ||
26 | ReactDom.render( | 19 | ReactDom.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 | ); |