import React from 'react'; import {StyleSheet, Text} from 'react-native'; import moment from 'moment'; interface DateLabelProps { timestamp: string; type: 'default' | 'short' | 'small'; decorate?: (date: string) => string; } const DateLabel: React.FC = ({ timestamp, type, decorate = (date) => `${date}`, }) => { let parsedDate = moment(timestamp); if (!parsedDate) { return ; } switch (type) { case 'default': return ( {decorate(parsedDate.format('h:mm a • MMM D, YYYY'))} ); case 'short': return ( {decorate(parsedDate.format('MMM D'))} ); case 'small': return ( {decorate(parsedDate.format('MMM D'))} ); } }; const styles = StyleSheet.create({ default: { fontSize: 15, color: '#c4c4c4', }, smallAndBlue: { fontSize: 14, fontWeight: 'bold', color: '#8FA9C2', }, }); export default DateLabel;