Skip to content

Commit c3cfdf6

Browse files
formatDate prop for MessageSimple component
1 parent 9a8d9a3 commit c3cfdf6

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/components/MessageSimple/MessageContent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export const MessageContent = themed(
249249
PropTypes.node,
250250
PropTypes.elementType,
251251
]),
252+
formatDate: PropTypes.func,
252253
};
253254

254255
static defaultProps = {
@@ -534,7 +535,9 @@ export const MessageContent = themed(
534535
{!MessageFooter && showTime ? (
535536
<MetaContainer>
536537
<MetaText alignment={pos}>
537-
{moment(message.created_at).format('h:mmA')}
538+
{this.props.formatDate
539+
? this.props.formatDate(message.created_at)
540+
: moment(message.created_at).format('h:mmA')}
538541
</MetaText>
539542
</MetaContainer>
540543
) : null}

src/components/MessageSimple/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const MessageSimple = themed(
169169
PropTypes.node,
170170
PropTypes.elementType,
171171
]),
172+
formatDate: PropTypes.func,
172173
};
173174

174175
static defaultProps = {

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ export interface MessageUIComponentProps
461461
/** https://github.com/beefe/react-native-actionsheet/blob/master/lib/styles.js */
462462
actionSheetStyles?: object;
463463
AttachmentFileIcon?: React.ElementType<FileIconUIComponentProps>;
464+
formatDate(date: string): string;
464465
}
465466

466467
export interface MessageRepliesUIComponentProps {

0 commit comments

Comments
 (0)