Add timeFormat prop (#273)

* Added property for time format

* Added property to readme
This commit is contained in:
Yosmany Garcia
2017-07-16 15:45:13 -07:00
committed by Kevin Cooper
parent 1e79078265
commit 187cf521c7
2 changed files with 4 additions and 1 deletions

View File

@@ -107,6 +107,7 @@ e.g.
- **`user`** _(Object)_ - User sending the messages: `{ _id, name, avatar }`
- **`onSend`** _(Function)_ - Callback when sending a message
- **`locale`** _(String)_ - Locale to localize the dates
- **`timeFormat`** _(String)_ - Format to use for rendering times; default is 'LT'
- **`isAnimated`** _(Bool)_ - Animates the view when the keyboard appears
- **`loadEarlier`** _(Bool)_ - Enables the "Load earlier messages" button
- **`onLoadEarlier`** _(Function)_ - Callback when loading earlier messages

View File

@@ -14,7 +14,7 @@ export default class Time extends React.Component {
return (
<View style={[styles[this.props.position].container, this.props.containerStyle[this.props.position]]}>
<Text style={[styles[this.props.position].text, this.props.textStyle[this.props.position]]}>
{moment(this.props.currentMessage.createdAt).locale(this.context.getLocale()).format('LT')}
{moment(this.props.currentMessage.createdAt).locale(this.context.getLocale()).format(this.props.timeFormat)}
</Text>
</View>
);
@@ -65,6 +65,7 @@ Time.defaultProps = {
},
containerStyle: {},
textStyle: {},
timeFormat: 'LT'
};
Time.propTypes = {
@@ -78,4 +79,5 @@ Time.propTypes = {
left: Text.propTypes.style,
right: Text.propTypes.style,
}),
timeFormat: React.PropTypes.string
};