Created
May 21, 2012 19:56
-
-
Save rwaldron/2764289 to your computer and use it in GitHub Desktop.
Demonstrate DateTimeFormat options for a variety of Locales
This file contains 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
/** | |
* Requires the most current version of Chrome Canary | |
* | |
* Demonstrates out of: | |
* | |
* v8Intl.DateTimeFormat([ locale ], options ).format() | |
* | |
* | |
*/ | |
var locales, dtfProps; | |
locales = [ | |
"en", | |
"de", | |
"es", | |
"jp", | |
"ar", | |
"fr", | |
"ko" | |
]; | |
dtfProps = { | |
weekday: [ "narrow", "short", "long" ], | |
era: [ "narrow", "short", "long" ], | |
year: [ "2-digit", "numeric" ], | |
month: [ "2-digit", "numeric", "narrow", "short", "long" ], | |
day: [ "2-digit", "numeric" ], | |
hour: [ "2-digit", "numeric" ], | |
minute: [ "2-digit", "numeric" ], | |
second: [ "2-digit", "numeric" ], | |
timeZoneName: [ "short", "long" ] | |
}; | |
locales.forEach(function( locale ) { | |
console.group( locale ); | |
Object.keys( dtfProps ).forEach(function( prop ) { | |
var allowables = this[ prop ]; | |
console.group( "\t" + prop ); | |
allowables.forEach(function( allow ) { | |
var options = {}; | |
options[ prop ] = allow; | |
console.log( "\t\t" + allow + ": " + | |
v8Intl.DateTimeFormat([ locale ], options ).format() | |
); | |
}); | |
console.groupEnd( "\t" + prop ); | |
}, dtfProps ); | |
console.groupEnd( locale ); | |
}); |
This file contains 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
en | |
weekday | |
narrow: M | |
short: Mon | |
long: Monday | |
era | |
narrow: 5/21/2012 A | |
short: 5/21/2012 AD | |
long: 5/21/2012 Anno Domini | |
year | |
2-digit: 12 | |
numeric: 2012 | |
month | |
2-digit: 05 | |
numeric: 5 | |
narrow: M | |
short: May | |
long: May | |
day | |
2-digit: 21 | |
numeric: 21 | |
hour | |
2-digit: 1 PM | |
numeric: 1 PM | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 17 | |
numeric: 17 | |
timeZoneName | |
short: 5/21/2012 PT | |
long: 5/21/2012 GMT-07:00 | |
de | |
weekday | |
narrow: M | |
short: Mo. | |
long: Montag | |
era | |
narrow: 21.5.2012 n. Chr. | |
short: 21.5.2012 n. Chr. | |
long: 21.5.2012 n. Chr. | |
year | |
2-digit: 12 | |
numeric: 2012 | |
month | |
2-digit: 05 | |
numeric: 5 | |
narrow: M | |
short: Mai | |
long: Mai | |
day | |
2-digit: 21 | |
numeric: 21 | |
hour | |
2-digit: 13 Uhr | |
numeric: 13 Uhr | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 17 | |
numeric: 17 | |
timeZoneName | |
short: 21.5.2012 Vereinigte Staaten (Los Angeles) | |
long: 21.5.2012 GMT-07:00 | |
es | |
weekday | |
narrow: L | |
short: lun | |
long: lunes | |
era | |
narrow: 21/5/2012 d.C. | |
short: 21/5/2012 d.C. | |
long: 21/5/2012 anno Dómini | |
year | |
2-digit: 12 | |
numeric: 2012 | |
month | |
2-digit: 05 | |
numeric: 5 | |
narrow: M | |
short: may | |
long: mayo | |
day | |
2-digit: 21 | |
numeric: 21 | |
hour | |
2-digit: 13 | |
numeric: 13 | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 17 | |
numeric: 17 | |
timeZoneName | |
short: 21/5/2012 PT | |
long: 21/5/2012 GMT-07:00 | |
jp | |
weekday | |
narrow: M | |
short: Mon | |
long: Monday | |
era | |
narrow: 5/21/2012 A | |
short: 5/21/2012 AD | |
long: 5/21/2012 Anno Domini | |
year | |
2-digit: 12 | |
numeric: 2012 | |
month | |
2-digit: 05 | |
numeric: 5 | |
narrow: M | |
short: May | |
long: May | |
day | |
2-digit: 21 | |
numeric: 21 | |
hour | |
2-digit: 1 PM | |
numeric: 1 PM | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 17 | |
numeric: 17 | |
timeZoneName | |
short: 5/21/2012 PT | |
long: 5/21/2012 GMT-07:00 | |
ar | |
weekday | |
narrow: ن | |
short: إثنين | |
long: الإثنين | |
era | |
narrow: ٢١/٥/٢٠١٢ م | |
short: ٢١/٥/٢٠١٢ م | |
long: ٢١/٥/٢٠١٢ ميلادي | |
year | |
2-digit: ١٢ | |
numeric: ٢٠١٢ | |
month | |
2-digit: ٠٥ | |
numeric: ٥ | |
narrow: و | |
short: مايو | |
long: مايو | |
day | |
2-digit: ٢١ | |
numeric: ٢١ | |
hour | |
2-digit: ١ م | |
numeric: ١ م | |
minute | |
2-digit: ١ | |
numeric: ١ | |
second | |
2-digit: ١٧ | |
numeric: ١٧ | |
timeZoneName | |
short: ٢١/٥/٢٠١٢ الولايات المتحدة الأمريكية (لوس انجلوس) | |
long: ٢١/٥/٢٠١٢ جرينتش-٠٧:٠٠ | |
fr | |
weekday | |
narrow: L | |
short: lun. | |
long: lundi | |
era | |
narrow: 21/5/2012 ap. J.-C. | |
short: 21/5/2012 ap. J.-C. | |
long: 21/5/2012 après Jésus-Christ | |
year | |
2-digit: 12 | |
numeric: 2012 | |
month | |
2-digit: 05 | |
numeric: 5 | |
narrow: M | |
short: mai | |
long: mai | |
day | |
2-digit: 21 | |
numeric: 21 | |
hour | |
2-digit: 13 | |
numeric: 13 | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 17 | |
numeric: 17 | |
timeZoneName | |
short: 21/5/2012 États-Unis (Los Angeles) | |
long: 21/5/2012 UTC-07:00 | |
ko | |
weekday | |
narrow: 월 | |
short: 월 | |
long: 월요일 | |
era | |
narrow: 2012년 5월 21일 서기 | |
short: 2012년 5월 21일 서기 | |
long: 2012년 5월 21일 서력기원 | |
year | |
2-digit: 12년 | |
numeric: 2012년 | |
month | |
2-digit: 05월 | |
numeric: 5월 | |
narrow: 5월 | |
short: 5월 | |
long: 5월 | |
day | |
2-digit: 21일 | |
numeric: 21일 | |
hour | |
2-digit: 오후 1시 | |
numeric: 오후 1시 | |
minute | |
2-digit: 1 | |
numeric: 1 | |
second | |
2-digit: 18 | |
numeric: 18 | |
timeZoneName | |
short: 2012년 5월 21일 미국 (로스앤젤레스) | |
long: 2012년 5월 21일 GMT-07:00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment