-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from gentlementlegen/fix/draft-only-review-req…
…uest fix: change to draft only on changes requested
- Loading branch information
Showing
6 changed files
with
41 additions
and
20 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,14 +1,33 @@ | ||
export function formatMillisecondsToDaysAndHours(milliseconds: number): string { | ||
export function formatMillisecondsToHumanReadable(milliseconds: number): string { | ||
if (milliseconds <= 0) { | ||
return "0 days and 0 hours"; | ||
return "< 1 minute"; | ||
} | ||
const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24)); | ||
const hours = Math.floor((milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
if (days === 0) { | ||
return `${hours} ${hours === 1 ? "hour" : "hours"}`; | ||
} else if (hours === 0) { | ||
return `${days} ${days === 1 ? "day" : "days"}`; | ||
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60)); | ||
const components: string[] = []; | ||
|
||
if (days > 0) { | ||
components.push(`${days} ${days === 1 ? "day" : "days"}`); | ||
} | ||
|
||
if (hours > 0) { | ||
components.push(`${hours} ${hours === 1 ? "hour" : "hours"}`); | ||
} | ||
|
||
if (minutes > 0) { | ||
components.push(`${minutes} ${minutes === 1 ? "minute" : "minutes"}`); | ||
} | ||
|
||
if (components.length === 0) { | ||
return "< 1 minute"; | ||
} | ||
|
||
if (components.length === 1) { | ||
return components[0]; | ||
} else if (components.length === 2) { | ||
return `${components[0]} and ${components[1]}`; | ||
} else { | ||
return `${days} ${days === 1 ? "day" : "days"} and ${hours} ${hours === 1 ? "hour" : "hours"}`; | ||
return `${components[0]}, ${components[1]}, and ${components[2]}`; | ||
} | ||
} |
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
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