Merge pull request #383 from kolplattformen/feature/no-year-if-same-year
style: 💄 Calendar date - remove year if current year
This commit is contained in:
commit
899ac06f52
|
@ -22,6 +22,17 @@ export const Calendar = () => {
|
|||
const { data } = useCalendar(child)
|
||||
const styles = useStyleSheet(themedStyles)
|
||||
|
||||
const formatStartDate = (startDate: moment.MomentInput) => {
|
||||
const date = moment(startDate)
|
||||
const output = `${date.format('dddd')} ${date.format(
|
||||
'll'
|
||||
)} • ${date.fromNow()}`
|
||||
|
||||
// Hack to remove yarn if it is this year
|
||||
const currentYear = moment().year().toString(10)
|
||||
return output.replace(currentYear, '')
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Week child={child} />
|
||||
|
@ -39,9 +50,7 @@ export const Calendar = () => {
|
|||
title={`${item.title}`}
|
||||
description={(props) => (
|
||||
<Text style={[props?.style, styles.description]}>
|
||||
{`${moment(item.startDate).format('dddd')} ${moment(
|
||||
item.startDate
|
||||
).format('ll')} (${moment(item.startDate).fromNow()})`}
|
||||
{formatStartDate(item.startDate)}
|
||||
</Text>
|
||||
)}
|
||||
accessoryLeft={CalendarOutlineIcon}
|
||||
|
|
Loading…
Reference in New Issue