From e90b9f47067ad687d6a2fa2f13b5825257107ed5 Mon Sep 17 00:00:00 2001 From: Aiz <66974576+Aiz0@users.noreply.github.com> Date: Thu, 22 Sep 2022 00:49:59 +0000 Subject: [PATCH] Improve premiere timestamp to be easier to read (#2559) * Improve premiere timestamp Removes the unesseccary parts of the timestamp, year and seconds. displays month as long name (eg., March) * fix linting... forgot to add the file again before commit. * get and use current locale set in freetube this fixes issues where os locale and freetube locale don't match * use 'default' when no locale is set in freetube. this defaults to system locale * use i18n to get locale and format date with intl * format date with intl.datetimeformat forgot to add file again after changes... * display year if current year is less than year of premiere date --- src/renderer/views/Watch/Watch.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index dbe3252e..3478eb06 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -415,7 +415,18 @@ export default Vue.extend({ if (typeof startTimestamp !== 'undefined') { const upcomingTimestamp = new Date(result.videoDetails.liveBroadcastDetails.startTimestamp) - this.upcomingTimestamp = upcomingTimestamp.toLocaleString() + const timestampOptions = { + month: 'long', + day: 'numeric', + hour: 'numeric', + minute: '2-digit' + } + if (new Date().getFullYear() < upcomingTimestamp.getFullYear()) { + Object.defineProperty(timestampOptions, 'year', { + value: 'numeric' + }) + } + this.upcomingTimestamp = Intl.DateTimeFormat(this.currentLocale, timestampOptions).format(upcomingTimestamp) let upcomingTimeLeft = upcomingTimestamp - new Date()