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/disabled.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/disabled.js')
-rw-r--r-- | examples/disabled.js | 28 |
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'; | |||
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); | 15 | const now = moment().hour(14).minute(30); |
18 | |||
19 | const now = new GregorianCalendar(TimePickerLocale.calendar); | ||
20 | now.setTime(Date.now()); | ||
21 | 16 | ||
22 | function generateOptions(length, excludedOptions) { | 17 | function generateOptions(length, excludedOptions) { |
23 | const arr = []; | 18 | const arr = []; |
@@ -30,7 +25,7 @@ function generateOptions(length, excludedOptions) { | |||
30 | } | 25 | } |
31 | 26 | ||
32 | function onChange(value) { | 27 | function onChange(value) { |
33 | console.log(value && formatter.format(value)); | 28 | console.log(value && value.format(str)); |
34 | } | 29 | } |
35 | 30 | ||
36 | function disabledHours() { | 31 | function disabledHours() { |
@@ -53,13 +48,14 @@ function disabledSeconds(h, m) { | |||
53 | } | 48 | } |
54 | 49 | ||
55 | ReactDom.render( | 50 | ReactDom.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 | ); |