/** * The examples provided by Facebook are for non-commercial testing and * evaluation purposes only. * * Facebook reserves all rights not expressly granted. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @flow */ 'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { DatePickerIOS, StyleSheet, Text, TextInput, View, } = ReactNative; var DatePickerExample = React.createClass({ getDefaultProps: function () { return { date: new Date(), timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60, }; }, getInitialState: function() { return { date: this.props.date, timeZoneOffsetInHours: this.props.timeZoneOffsetInHours, }; }, onDateChange: function(date) { this.setState({date: date}); }, onTimezoneChange: function(event) { var offset = parseInt(event.nativeEvent.text, 10); if (isNaN(offset)) { return; } this.setState({timeZoneOffsetInHours: offset}); }, render: function() { // Ideally, the timezone input would be a picker rather than a // text input, but we don't have any pickers yet :( return ( { this.state.date.toLocaleDateString() + ' ' + this.state.date.toLocaleTimeString() } hours from UTC ); }, }); var WithLabel = React.createClass({ render: function() { return ( {this.props.label} {this.props.children} ); } }); var Heading = React.createClass({ render: function() { return ( {this.props.label} ); } }); exports.displayName = (undefined: ?string); exports.title = ''; exports.description = 'Select dates and times using the native UIDatePicker.'; exports.examples = [ { title: '', render: function(): ReactElement { return ; }, }]; var styles = StyleSheet.create({ textinput: { height: 26, width: 50, borderWidth: 0.5, borderColor: '#0f0f0f', padding: 4, fontSize: 13, }, labelContainer: { flexDirection: 'row', alignItems: 'center', marginVertical: 2, }, labelView: { marginRight: 10, paddingVertical: 2, }, label: { fontWeight: '500', }, headingContainer: { padding: 4, backgroundColor: '#f6f7f8', }, heading: { fontWeight: '500', fontSize: 14, }, });