Skip to content

Commit

Permalink
Merge pull request #415 from protofire/weeks_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
leolower authored May 27, 2020
2 parents 1c32269 + c5a67e1 commit a4958c3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ export const timeLeft = (end): string => {
const minsDiff = differenceInMinutes(end_date, today)
const hoursDiff = differenceInHours(end_date, today)
const daysDiff = differenceInDays(end_date, today)
const weeksDiff = differenceInWeeks(end_date, today)
const monthsDiff = differenceInMonths(end_date, today)
const yearsDiff = differenceInYears(end_date, today)

if (yearsDiff > 0) return yearsDiff === 1 ? `${yearsDiff} year` : `${yearsDiff} year`
if (yearsDiff > 0) return yearsDiff === 1 ? `${yearsDiff} year` : `${yearsDiff} years`
if (monthsDiff > 0) return monthsDiff === 1 ? `${monthsDiff} month` : `${monthsDiff} months`
if (weeksDiff > 0) return weeksDiff === 1 ? `${daysDiff} week` : `${daysDiff} week`
if (daysDiff > 0) return daysDiff === 1 ? `${daysDiff} day` : `${daysDiff} days`
if (hoursDiff > 0) return hoursDiff === 1 ? `${daysDiff} hour` : `${hoursDiff} hours`
if (hoursDiff > 0) return hoursDiff === 1 ? `${hoursDiff} hour` : `${hoursDiff} hours`
return minsDiff === 1 ? `${minsDiff} minute` : `${minsDiff} minutes`
}

Expand Down

0 comments on commit a4958c3

Please sign in to comment.