import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import DateTimePicker from 'react-datetime'; import { registerComponent } from 'meteor/vulcan:core'; class Time extends PureComponent { constructor(props) { super(props); this.updateDate = this.updateDate.bind(this); } // when the datetime picker has mounted, SmartForm will catch the date value (no formsy mixin in this component) componentDidMount() { if (this.props.value) { this.context.updateCurrentValues({[this.props.name]: this.props.value}); } } updateDate(mDate) { // if this is a properly formatted moment date, update time if (typeof mDate === 'object') { this.context.updateCurrentValues({[this.props.name]: mDate.format('HH:mm')}); } } render() { const date = new Date(); // transform time string into date object to work inside datetimepicker const time = this.props.value; if (time) { date.setHours(parseInt(time.substr(0,2)), parseInt(time.substr(3,5))); } else { date.setHours(0,0); } return (