Created
March 31, 2021 22:26
-
-
Save jdanyow/18442ed7353482b72e52126ee6dc7653 to your computer and use it in GitHub Desktop.
Duration formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>GistRun</title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<h1>Hello world!</h1> | |
<pre id="outputPre"></pre> | |
<script> | |
const locales = [ | |
'en-us', | |
'cs-cz', | |
'de-de', | |
'es-es', | |
'fr-fr', | |
'hu-hu', | |
'it-it', | |
'ja-jp', | |
'ko-kr', | |
'nl-nl', | |
'pl-pl', | |
'pt-br', | |
'pt-pt', | |
'ru-ru', | |
'sv-se', | |
'tr-tr', | |
'zh-cn', | |
'zh-tw', | |
'ar-sa', | |
'bg-bg', | |
'ca-es', | |
'da-dk', | |
'de-AT', | |
'de-CH', | |
'el-gr', | |
'en-AU', | |
'en-CA', | |
'en-GB', | |
'en-IE', | |
'en-IN', | |
'en-MY', | |
'en-NZ', | |
'en-SG', | |
'en-ZA', | |
'es-MX', | |
'et-ee', | |
'eu-es', | |
'fi-fi', | |
'fr-BE', | |
'fr-CA', | |
'fr-CH', | |
'gl-es', | |
'he-il', | |
'hi-in', | |
'hr-hr', | |
'id-id', | |
'is-is', | |
'it-CH', | |
'kk-kz', | |
'lt-lt', | |
'lv-lv', | |
'ms-my', | |
'nb-NO', | |
'nl-BE', | |
'ro-ro', | |
'sk-sk', | |
'sl-si', | |
'sr-cyrl-rs', | |
'sr-latn-rs', | |
'th-th', | |
'uk-ua', | |
'vi-vn', | |
'zh-hk', | |
'bs-latn-ba', | |
'bs-cyrl-ba', | |
'ga-ie', | |
'lb-lu', | |
'mt-mt', | |
'fil-ph' | |
].map(locale => locale.toLowerCase()); | |
outputPre.textContent = locales.map(locale => { | |
const secondsFormat = new Intl.NumberFormat(locale, { style: 'unit', unit: 'second', unitDisplay: 'narrow' }); | |
const minutesFormat = new Intl.NumberFormat(locale, { style: 'unit', unit: 'minute', unitDisplay: 'short' }); | |
return `"${secondsFormat.format(30)}"\t\t"${minutesFormat.format(3.5)}"`; | |
}).join('\n') | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Hello World!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* todo: add styles */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment