MCPcopy Index your code
hub / github.com/MALSync/MALSync / shortTime

Function shortTime

src/utils/IntlWrapper.ts:280–343  ·  view source on GitHub ↗
(time: DurationFormat)

Source from the content-addressed store, hash-verified

278
279// Utility for exporting
280export function shortTime(time: DurationFormat): DurationFormat {
281 let totalDays = time.days || 0;
282 if (time.years) {
283 if (time.years > 1) {
284 if (time.days && time.days > 182) {
285 return {
286 years: time.years + 1,
287 };
288 }
289 return {
290 years: time.years,
291 };
292 }
293 return {
294 years: time.years,
295 days: time.days,
296 };
297 }
298 if (time.months || time.weeks) {
299 totalDays += time.months ? time.months * 30 : 0;
300 totalDays += time.weeks ? time.weeks * 7 : 0;
301 }
302 if (totalDays) {
303 if (totalDays > 3) {
304 if (time.hours && time.hours > 11) {
305 return {
306 days: totalDays + 1,
307 };
308 }
309 return {
310 days: totalDays,
311 };
312 }
313 return {
314 days: totalDays,
315 hours: time.hours,
316 };
317 }
318 if (time.hours) {
319 if (time.hours > 5) {
320 if (time.minutes && time.minutes > 29) {
321 return {
322 hours: time.hours + 1,
323 };
324 }
325 return {
326 hours: time.hours,
327 };
328 }
329 return {
330 hours: time.hours,
331 minutes: time.minutes,
332 };
333 }
334 if (time.minutes && time.minutes > 14) {
335 return {
336 minutes: time.minutes,
337 };

Callers 1

processMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected