diff options
Diffstat (limited to 'examples/pick-time.js')
-rw-r--r-- | examples/pick-time.js | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/examples/pick-time.js b/examples/pick-time.js index 8fa7831..835e1e1 100644 --- a/examples/pick-time.js +++ b/examples/pick-time.js | |||
@@ -5,30 +5,25 @@ 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 | 15 | ||
22 | function onChange(value) { | 16 | function onChange(value) { |
23 | console.log(value && formatter.format(value)); | 17 | console.log(value && value.format(str)); |
24 | } | 18 | } |
25 | 19 | ||
26 | ReactDom.render( | 20 | ReactDom.render( |
27 | <TimePicker formatter={formatter} locale={TimePickerLocale} | 21 | <TimePicker |
28 | style={{width: 100}} | 22 | style={{ width: 100 }} |
29 | showSecond={showSecond} | 23 | showSecond={showSecond} |
30 | defaultValue={now} | 24 | defaultValue={moment()} |
31 | className="xxx" | 25 | className="xxx" |
32 | onChange={onChange} />, | 26 | onChange={onChange} |
27 | />, | ||
33 | document.getElementById('__react-content') | 28 | document.getElementById('__react-content') |
34 | ); | 29 | ); |