From 9acc1ceef4f9d340f7e559a1c4fb8cc91f7b23df Mon Sep 17 00:00:00 2001
From: Kenny <27463495+Frontesque@users.noreply.github.com>
Date: Thu, 5 May 2022 08:18:38 -0400
Subject: [PATCH 1/2] fix: :bug: Fix how utils.humanTime() works
---
NUXT/plugins/utils.js | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/NUXT/plugins/utils.js b/NUXT/plugins/utils.js
index b883f12..b40b13d 100644
--- a/NUXT/plugins/utils.js
+++ b/NUXT/plugins/utils.js
@@ -78,18 +78,24 @@ function linkParser(url) {
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
//--- Convert Time To Human Readable String ---//
-function humanTime(givenTime) {
- const minutes = Math.floor(givenTime / 60);
- const seconds = givenTime - minutes * 60;
- const hours = Math.floor(givenTime / 3600);
- return {
- formatted: (hours ? hours+":" : "") + `${minutes}:${seconds}`,
- raw: {
- hours: hours,
- minutes: minutes,
- seconds: seconds
- }
+function humanTime(seconds) {
+ let levels = [
+ Math.floor(seconds / 31536000), //Years
+ Math.floor((seconds % 31536000) / 86400), //Days
+ Math.floor(((seconds % 31536000) % 86400) / 3600), //Hours
+ Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), //Minutes
+ (((seconds % 31536000) % 86400) % 3600) % 60, //Seconds
+ ];
+
+ let returntext = new String();
+ for (const i in levels) {
+ const num = levels[i].toString().length == 1 ? "0"+levels[i] : levels[i]; // If Number Is Single Digit, Add 0 In Front
+
+ returntext += ":"+num;
}
+ while (returntext.startsWith(":00")) { returntext = returntext.substring(3); } // Remove Prepending 0s (eg. 00:00:00:01:00)
+ if (returntext.startsWith(":0")) { returntext = returntext.substring(2); } else { returntext = returntext.substring(1); } // Prevent Time Starting With 0 (eg. 01:00)
+ return returntext
}
//--- End Convert Time To Human Readable String ---//
From cce0d90802841e55fb01755ee12195d9c387f6b1 Mon Sep 17 00:00:00 2001
From: Kenny <27463495+Frontesque@users.noreply.github.com>
Date: Thu, 5 May 2022 08:28:32 -0400
Subject: [PATCH 2/2] feat: :sparkles: beta player time info
---
NUXT/components/Player/controls.vue | 4 ++--
NUXT/plugins/utils.js | 24 +-----------------------
NUXT/plugins/vuetube.js | 27 +++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/NUXT/components/Player/controls.vue b/NUXT/components/Player/controls.vue
index c28c7f3..3a968ae 100644
--- a/NUXT/components/Player/controls.vue
+++ b/NUXT/components/Player/controls.vue
@@ -9,7 +9,7 @@
- {{ watched }} / {{ video.duration }}
+ {{ watched }} / {{ $vuetube.humanTime(video.duration) }}
@@ -67,7 +67,7 @@
mounted() {
this.video.ontimeupdate = () => {
console.log(this.video.currentTime)
- this.watched = this.video.currentTime;
+ this.watched = this.$vuetube.humanTime(this.video.currentTime);
};
},
diff --git a/NUXT/plugins/utils.js b/NUXT/plugins/utils.js
index b40b13d..ab21e15 100644
--- a/NUXT/plugins/utils.js
+++ b/NUXT/plugins/utils.js
@@ -77,28 +77,6 @@ function linkParser(url) {
}
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
-//--- Convert Time To Human Readable String ---//
-function humanTime(seconds) {
- let levels = [
- Math.floor(seconds / 31536000), //Years
- Math.floor((seconds % 31536000) / 86400), //Days
- Math.floor(((seconds % 31536000) % 86400) / 3600), //Hours
- Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), //Minutes
- (((seconds % 31536000) % 86400) % 3600) % 60, //Seconds
- ];
-
- let returntext = new String();
- for (const i in levels) {
- const num = levels[i].toString().length == 1 ? "0"+levels[i] : levels[i]; // If Number Is Single Digit, Add 0 In Front
-
- returntext += ":"+num;
- }
- while (returntext.startsWith(":00")) { returntext = returntext.substring(3); } // Remove Prepending 0s (eg. 00:00:00:01:00)
- if (returntext.startsWith(":0")) { returntext = returntext.substring(2); } else { returntext = returntext.substring(1); } // Prevent Time Starting With 0 (eg. 01:00)
- return returntext
-}
-//--- End Convert Time To Human Readable String ---//
-
module.exports = {
getBetweenStrings,
hexToRgb,
@@ -107,5 +85,5 @@ module.exports = {
getMutationByKey,
linkParser,
delay,
- parseEmoji,
+ parseEmoji
};
diff --git a/NUXT/plugins/vuetube.js b/NUXT/plugins/vuetube.js
index 428964a..1d9d069 100644
--- a/NUXT/plugins/vuetube.js
+++ b/NUXT/plugins/vuetube.js
@@ -109,6 +109,33 @@ const module = {
rgbToHex(r, g, b) {
return rgbToHex(r, g, b);
},
+
+
+ //--- Convert Time To Human Readable String ---//
+ humanTime(seconds=0) {
+ seconds = Math.floor(seconds); // Not doing this seems to break the calculation
+ let levels = [
+ Math.floor(seconds / 31536000), //Years
+ Math.floor((seconds % 31536000) / 86400), //Days
+ Math.floor(((seconds % 31536000) % 86400) / 3600), //Hours
+ Math.floor((((seconds % 31536000) % 86400) % 3600) / 60), //Minutes
+ (((seconds % 31536000) % 86400) % 3600) % 60, //Seconds
+ ];
+
+ let returntext = new String();
+ for (const i in levels) {
+ const num = levels[i].toString().length == 1 ? "0"+levels[i] : levels[i]; // If Number Is Single Digit, Add 0 In Front
+
+ returntext += ":"+num;
+ }
+ while (returntext.startsWith(":00")) { returntext = returntext.substring(3); } // Remove Prepending 0s (eg. 00:00:00:01:00)
+ if (returntext.startsWith(":0")) { returntext = returntext.substring(2); } else { returntext = returntext.substring(1); } // Prevent Time Starting With 0 (eg. 01:00)
+ console.log("Human Time:", returntext)
+ return returntext;
+ }
+//--- End Convert Time To Human Readable String ---//
+
+
};
//--- Start ---//