MCPcopy Create free account
hub / github.com/dailydotdev/apps / getReadHistoryDateFormat

Function getReadHistoryDateFormat

packages/shared/src/lib/dateFormat.ts:203–221  ·  view source on GitHub ↗
(currentDate: Date)

Source from the content-addressed store, hash-verified

201};
202
203export const getReadHistoryDateFormat = (currentDate: Date): string => {
204 const today = new Date();
205
206 if (isDateOnlyEqual(today, currentDate)) {
207 return 'Today';
208 }
209
210 if (isDateOnlyEqual(today, addDays(currentDate, 1))) {
211 return 'Yesterday';
212 }
213
214 const dayOfTheWeek = format(currentDate, 'EEE');
215 const dayOfTheMonth = currentDate.getDate();
216 const month = format(currentDate, 'MMM');
217 const currentYear = currentDate.getFullYear();
218 const year = currentYear === today.getFullYear() ? '' : ` ${currentYear}`;
219
220 return `${dayOfTheWeek}, ${dayOfTheMonth} ${month}${year}`;
221};
222
223export const getTopReaderBadgeDateFormat = (date: string | Date): string => {
224 return new Date(date).toLocaleString('en-US', {

Callers 2

dateFormat.spec.tsFile · 0.90
formatDateFunction · 0.85

Calls 1

isDateOnlyEqualFunction · 0.85

Tested by

no test coverage detected