forked from henb13/jre-missing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format last checked string to include hours and days
- Loading branch information
Showing
5 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
.right { | ||
display: flex; | ||
align-items: flex-start; | ||
margin: 11rem 0rem 9rem 56vw; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export default function formatTimeString(time) { | ||
if (time < 1) { | ||
return "less than a minute ago"; | ||
} | ||
|
||
if (time < 60) { | ||
const minutesString = time === 1 ? "minute" : "minutes"; | ||
return `${time} ${minutesString} ago`; | ||
} | ||
if (time >= 60 && time < 1440) { | ||
const hours = Math.floor(time / 60); | ||
const hoursString = hours === 1 ? "hour" : "hours"; | ||
const minutes = time % 60; | ||
const minutesString = minutes === 1 ? "minute" : "minutes"; | ||
|
||
return `${hours} ${hoursString} ${ | ||
minutes === 0 ? "" : `and ${minutes} ${minutesString} ` | ||
}ago`; | ||
} | ||
|
||
const days = Math.floor(time / (60 * 60 * 24)); | ||
const daysString = days === 1 ? "day" : "days"; | ||
return `${days} ${daysString} ago`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters