Skip to content

Commit

Permalink
added hour handling for longer videos
Browse files Browse the repository at this point in the history
  • Loading branch information
deepansh96 committed Jul 3, 2024
1 parent 37d0b29 commit 71ddf03
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1888,16 +1888,23 @@ export default {
},
// format a number based timestamp like 24.32 to a string like 00:24:320
// or a number like 3600.32 to a string like 01:00:320
formatTimestamp(timestamp) {
const minutes = Math.floor(timestamp / 60);
const hours = Math.floor(timestamp / 3600);
const minutes = Math.floor((timestamp % 3600) / 60);
const seconds = Math.floor(timestamp % 60);
const milliseconds = Math.floor((timestamp % 1) * 1000);
const formattedHours = String(hours).padStart(2, '0');
const formattedMinutes = String(minutes).padStart(2, '0');
const formattedSeconds = String(seconds).padStart(2, '0');
const formattedMilliseconds = String(milliseconds).padStart(3, '0');
return `${formattedMinutes}:${formattedSeconds}:${formattedMilliseconds}`;
if (hours > 0) {
return `${formattedHours}:${formattedMinutes}:${formattedSeconds}:${formattedMilliseconds}`;
} else {
return `${formattedMinutes}:${formattedSeconds}:${formattedMilliseconds}`;
}
},
/**
Expand Down

0 comments on commit 71ddf03

Please sign in to comment.