<commit_before>// @flow
// Copied from https://github.com/xgfe/react-native-datepicker

import * as React from 'react'
import {Keyboard} from 'react-native'
import moment from 'moment-timezone'

import {DatePicker as ActualDatePicker} from './datepicker'

const FORMATS = {
	date: 'YYYY-MM-DD',
	datetime: 'YYYY-MM-DD HH:mm',
	time: 'HH:mm',
}

type StyleSheetRules = Object | number | false | Array<StyleSheetRules>

type Props = {
	androidMode: 'calendar' | 'spinner' | 'default',
	initialDate: moment,
	duration?: number,
	format?: string,
	height?: number,
	minuteInterval?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30,
	mode: 'date' | 'datetime' | 'time',
	onDateChange: moment => any,
	style?: StyleSheetRules,
}

type State = {
	date: moment,
	timezone: string,
}

export class DatePicker extends React.Component<Props, State> {
	static defaultProps = {
		mode: 'date',
		androidMode: 'default',
		onDateChange: () => null,
	}

	_ref: any

	state = {
		date: this.props.initialDate,
		timezone: this.props.initialDate.tz(),
	}

	componentDidMount() {
		this.setState(() => ({
			date: this.props.initialDate,
			timezone: this.props.initialDate.tz(),
		}))
	}

	componentWillReceiveProps(nextProps: Props) {
		if (nextProps.initialDate !== this.props.initialDate) {
			this.setState(() => ({
				date: nextProps.initialDate,
				timezone: nextProps.initialDate.tz(),
			}))
		}
	}

	formatDate = (date: moment) => {
		const {mode, format = FORMATS[mode]} = this.props
		return moment(date).format(format)<commit_msg>remove duplicate componentDidMount from Datepicker<commit_after>// @flow
// Copied from https://github.com/xgfe/react-native-datepicker

import * as React from 'react'
import {Keyboard} from 'react-native'
import moment from 'moment-timezone'

import {DatePicker as ActualDatePicker} from './datepicker'

const FORMATS = {
	date: 'YYYY-MM-DD',
	datetime: 'YYYY-MM-DD HH:mm',
	time: 'HH:mm',
}

type StyleSheetRules = Object | number | false | Array<StyleSheetRules>

type Props = {
	androidMode: 'calendar' | 'spinner' | 'default',
	initialDate: moment,
	duration?: number,
	format?: string,
	height?: number,
	minuteInterval?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30,
	mode: 'date' | 'datetime' | 'time',
	onDateChange: moment => any,
	style?: StyleSheetRules,
}

type State = {
	date: moment,
	timezone: string,
}

export class DatePicker extends React.Component<Props, State> {
	static defaultProps = {
		mode: 'date',
		androidMode: 'default',
		onDateChange: () => null,
	}

	_ref: any

	state = {
		date: this.props.initialDate,
		timezone: this.props.initialDate.tz(),
	}

	componentWillReceiveProps(nextProps: Props) {
		if (nextProps.initialDate !== this.props.initialDate) {
			this.setState(() => ({
				date: nextProps.initialDate,
				timezone: nextProps.initialDate.tz(),
			}))
		}
	}

	formatDate = (date: moment) => {
		const {mode, format = FORMATS[mode]} = this.props
		return moment(date).format(format)
{'fraction_non_alphanumeric': 0.15290933694181327, 'fraction_numerical': 0.010825439783491205, 'mean_word_length': 4.124783362218371, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7547689', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1013, 'n_words': 251}