aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/pick-time.js
diff options
context:
space:
mode:
authorafc163 <afc163@gmail.com>2016-11-11 12:10:26 +0800
committerafc163 <afc163@gmail.com>2016-11-11 12:10:26 +0800
commit614f6c90232d890984d0f4f2f13ff41fdb144b27 (patch)
treece1a9be06b3264fd9fc09b3c2b028646db03a322 /examples/pick-time.js
parentcb5a445c75c7117c7c705d615099086274c2b254 (diff)
parentf429b4a79df25c9eadc3901e2483716835cc7de7 (diff)
downloadtime-picker-614f6c90232d890984d0f4f2f13ff41fdb144b27.tar.gz
time-picker-614f6c90232d890984d0f4f2f13ff41fdb144b27.tar.zst
time-picker-614f6c90232d890984d0f4f2f13ff41fdb144b27.zip
Merge branch 'master' of github.com:react-component/time-picker
Diffstat (limited to 'examples/pick-time.js')
-rw-r--r--examples/pick-time.js23
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';
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 15
22function onChange(value) { 16function onChange(value) {
23 console.log(value && formatter.format(value)); 17 console.log(value && value.format(str));
24} 18}
25 19
26ReactDom.render( 20ReactDom.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);