Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

feat: use Intl.DateTimeFormat

Christian Feia23ceaee690d
diff --git a/client/components/video-element.js b/client/components/video-element.js
index 2798b9d..b1e2e07 100644
--- a/client/components/video-element.js
+++ b/client/components/video-element.js
@@ -223,8 +223,12 @@ customElements.define('video-element', VideoElement)
function tryFormatDate(date) {
try {
- return new Date(date).toLocaleDateString(navigator.language || 'en-US').substring(0, 10)
+ return new Intl.DateTimeFormat(navigator.language, {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ }).format(new Date(date))
} catch (err) {
- return 'N/A'
+ return (date || '').substring(0, 10)
}
}