MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / formatTime

Function formatTime

frontend/src/utils/guideUtils.js:231–248  ·  view source on GitHub ↗
(time, dateFormat)

Source from the content-addressed store, hash-verified

229};
230
231export const formatTime = (time, dateFormat) => {
232 const today = startOfDay(getNow());
233 const tomorrow = add(today, 1, 'day');
234 const weekLater = add(today, 7, 'day');
235 const day = startOfDay(time);
236
237 if (isSame(day, today, 'day')) {
238 return 'Today';
239 } else if (isSame(day, tomorrow, 'day')) {
240 return 'Tomorrow';
241 } else if (isBefore(day, weekLater)) {
242 // Within a week, show day name
243 return format(time, 'dddd');
244 } else {
245 // Beyond a week, show month and day
246 return format(time, dateFormat);
247 }
248};
249
250export const calculateHourTimeline = (start, end, formatDayLabel) => {
251 const hours = [];

Callers 2

ConnectionProgressFunction · 0.90
TVChannelGuideFunction · 0.90

Calls 6

startOfDayFunction · 0.90
getNowFunction · 0.90
addFunction · 0.90
isSameFunction · 0.90
isBeforeFunction · 0.90
formatFunction · 0.90

Tested by

no test coverage detected