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
This commit is contained in:
parent
061a7c8db1
commit
e90b9f4706
|
@ -415,7 +415,18 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (typeof startTimestamp !== 'undefined') {
|
if (typeof startTimestamp !== 'undefined') {
|
||||||
const upcomingTimestamp = new Date(result.videoDetails.liveBroadcastDetails.startTimestamp)
|
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()
|
let upcomingTimeLeft = upcomingTimestamp - new Date()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue