Skip to content

Commit

Permalink
Can't use pretty-ms so use humanizeDuration instead
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Aug 28, 2024
1 parent 6fe9ac1 commit 4dc1995
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
65 changes: 24 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@
"@tanstack/react-query": "^5.14.0",
"@tanstack/react-query-persist-client": "^5.14.0",
"@tauri-apps/api": "^1.5.2",
"@types/humanize-duration": "^3.27.4",
"@types/lodash": "^4.14.202",
"async-wait-until": "^2.0.12",
"date-fns": "^2.30.0",
"dompurify": "^3.0.6",
"gray-matter": "^4.0.3",
"humanize-duration": "^3.32.1",
"is-online": "^11.0.0",
"js-video-url-parser": "^0.5.1",
"lodash": "^4.17.21",
"marked": "^11.1.0",
"pretty-ms": "^9.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
Expand Down
26 changes: 21 additions & 5 deletions src/utils/timeFormat.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { intlFormatDistance } from "date-fns";
import prettyMilliseconds from "pretty-ms";
import humanizeDuration from "humanize-duration";

export const millisToDisplayLength = (length: number, long = false) => {
return prettyMilliseconds(length, {
colonNotation: !long,
secondsDecimalDigits: 0,
});
if (long) {
return humanizeDuration(length, {
round: true
});
} else {
const totalSeconds = Math.round(length / 1000);
const totalMinutes = Math.floor(totalSeconds / 60);

const seconds = totalSeconds % 60;
const minutes = totalMinutes % 60;
const hours = Math.floor(totalMinutes / 60);

const secondsStr = seconds.toString().padStart(2, "0");

if (hours === 0) {
return `${minutes}:${secondsStr}`;
} else {
return `${hours}:${minutes}:${secondsStr}`;
}
}
};

export const isConsideredNewRelease = (releaseDate: string, newestInSetlist: string) => {
Expand Down

0 comments on commit 4dc1995

Please sign in to comment.