From 4984ed85e54f442998a335db70618d6184fa397e Mon Sep 17 00:00:00 2001 From: yiminghe Date: Thu, 4 Aug 2016 19:53:55 +0800 Subject: 2.x :boom: --- examples/disabled.js | 28 ++++++++++++---------------- examples/hidden.js | 30 +++++++++++++----------------- examples/pick-time.js | 23 +++++++++-------------- examples/value-and-defaultValue.js | 27 +++++++++++---------------- 4 files changed, 45 insertions(+), 63 deletions(-) (limited to 'examples') 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'; import React from 'react'; import ReactDom from 'react-dom'; -import GregorianCalendar from 'gregorian-calendar'; -import DateTimeFormat from 'gregorian-calendar-format'; +import moment from 'moment'; import TimePicker from 'rc-time-picker'; -import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; const showSecond = true; const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; -const formatter = new DateTimeFormat(str); - -const now = new GregorianCalendar(TimePickerLocale.calendar); -now.setTime(Date.now()); +const now = moment().hour(14).minute(30); function generateOptions(length, excludedOptions) { const arr = []; @@ -30,7 +25,7 @@ function generateOptions(length, excludedOptions) { } function onChange(value) { - console.log(value && formatter.format(value)); + console.log(value && value.format(str)); } function disabledHours() { @@ -53,13 +48,14 @@ function disabledSeconds(h, m) { } ReactDom.render( - , + , document.getElementById('__react-content') ); 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'; import React from 'react'; import ReactDom from 'react-dom'; -import GregorianCalendar from 'gregorian-calendar'; -import DateTimeFormat from 'gregorian-calendar-format'; +import moment from 'moment'; import TimePicker from 'rc-time-picker'; -import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; const showSecond = true; const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; -const formatter = new DateTimeFormat(str); - -const now = new GregorianCalendar(TimePickerLocale.calendar); -now.setTime(Date.now()); - function onChange(value) { - console.log(value && formatter.format(value)); + console.log(value && value.format(str)); } ReactDom.render( - [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} - disabledMinutes={() => [0, 2, 4, 6, 8]} - hideDisabledOptions />, + [0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} + disabledMinutes={() => [0, 2, 4, 6, 8]} + hideDisabledOptions + />, document.getElementById('__react-content') ); 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'; import React from 'react'; import ReactDom from 'react-dom'; -import GregorianCalendar from 'gregorian-calendar'; -import DateTimeFormat from 'gregorian-calendar-format'; +import moment from 'moment'; import TimePicker from 'rc-time-picker'; -import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; const showSecond = true; const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; -const formatter = new DateTimeFormat(str); - -const now = new GregorianCalendar(TimePickerLocale.calendar); -now.setTime(Date.now()); function onChange(value) { - console.log(value && formatter.format(value)); + console.log(value && value.format(str)); } ReactDom.render( - , + , document.getElementById('__react-content') ); diff --git a/examples/value-and-defaultValue.js b/examples/value-and-defaultValue.js index 1be30cc..0e1aa14 100644 --- a/examples/value-and-defaultValue.js +++ b/examples/value-and-defaultValue.js @@ -4,25 +4,17 @@ import 'rc-time-picker/assets/index.less'; import React from 'react'; import ReactDom from 'react-dom'; - -import GregorianCalendar from 'gregorian-calendar'; -import DateTimeFormat from 'gregorian-calendar-format'; +import moment from 'moment'; import TimePicker from 'rc-time-picker'; -import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; - -const formatter = new DateTimeFormat('HH:mm:ss'); - -const now = new GregorianCalendar(TimePickerLocale.calendar); -now.setTime(Date.now()); const App = React.createClass({ getInitialState() { return { - value: now, + value: moment(), }; }, handleValueChange(value) { - console.log(value && formatter.format(value)); + console.log(value && value.format('HH:mm:ss')); this.setState({ value }); }, clear() { @@ -33,11 +25,14 @@ const App = React.createClass({ render() { return (
- - + +
); -- cgit v1.2.3