boolean-uk / team-dev-frontend-client

1 stars 11 forks source link

Within the post date, display 'today' or 'yesterday' (+ time) if applicable #242

Closed MattVwaves closed 1 year ago

MattVwaves commented 1 year ago

Requirements

Implementation

const today = format(new Date(), 'MMMM d') const yesterday = isYesterday(new Date(today) const postDay = format(parseISO(post.createdAt), 'MMMM d')

Logi13 commented 1 year ago

Just a note on this: With the format in this post it will display Month day -> today will be December 5, yesterday will be December 4 so it will not be in the format shown in the example. I would suggest to add an accurate example on how the day will look like or update the format. You can see the formats in the documentation of date-fns: https://date-fns.org/v2.29.3/docs/format

MattVwaves commented 1 year ago

ah actually getting today and yesterday is just to check if it is today or yesterday. When I said 'the current date logic' that meant what is already in the app: const date = format(parseISO(post.createdAt), 'MMMM d, yyyy h:mm a')

MattVwaves commented 1 year ago

to be clearer I mean I'm checking today and yesterday with postDay