Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
v-if="audioVideoUpload && selectedDuration === 'exactTime'"
class="defaultUpload md2 sm3"
>
{{ defaultUploadTime }}
{{ convertToHHMMSS(defaultUploadTime) }}
</VFlex>
<VFlex
v-else-if="selectedDuration === 'shortActivity' || selectedDuration === 'longActivity'"
Expand Down Expand Up @@ -167,6 +167,20 @@
handleInput(value) {
this.$emit('input', this.convertToSeconds(value));
},
convertToHHMMSS(totalSeconds) {
if (totalSeconds !== null && Number.isInteger(totalSeconds)) {
const hours = Math.floor(totalSeconds / 3600)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method will give the same result and seems a little simpler: https://stackoverflow.com/a/25279399

Copy link
Copy Markdown
Member Author

@vkWeb vkWeb Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That implementation breaks when input seconds are greater than or equal to 86400 seconds.

On 86400 seconds, it outputs 00:00:00. The expected output should be 24:00:00. Date objects are relative to specific parameters like timezone, etc. And our use case is absolute in nature. So, IMO the current implementation feels more robust to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An excellent point!

.toString()
.padStart(2, 0);
const minutes = Math.floor((totalSeconds % 3600) / 60)
.toString()
.padStart(2, 0);
const seconds = ((totalSeconds % 3600) % 60).toString().padStart(2, 0);
return `${hours}:${minutes}:${seconds}`;
} else {
return totalSeconds;
}
},
},
$trs: {
minutesRequired: 'Minutes',
Expand Down