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

Function getReadHistoryDateFormat

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

Source from the content-addressed store, hash-verified

186};
187
188export const getReadHistoryDateFormat = (currentDate: Date): string => {
189 const today = new Date();
190
191 if (isDateOnlyEqual(today, currentDate)) {
192 return 'Today';
193 }
194
195 if (isDateOnlyEqual(today, addDays(currentDate, 1))) {
196 return 'Yesterday';
197 }
198
199 const dayOfTheWeek = format(currentDate, 'EEE');
200 const dayOfTheMonth = currentDate.getDate();
201 const month = format(currentDate, 'MMM');
202 const currentYear = currentDate.getFullYear();
203 const year = currentYear === today.getFullYear() ? '' : ` ${currentYear}`;
204
205 return `${dayOfTheWeek}, ${dayOfTheMonth} ${month}${year}`;
206};
207
208export const getTopReaderBadgeDateFormat = (date: string | Date): string => {
209 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