daily pastebin goal
84%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Requires the most current version of Chrome Canary
  3.  *
  4.  * Demonstrates out of:
  5.  *
  6.  *     v8Intl.DateTimeFormat([ locale ], options ).format()
  7.  *
  8.  *
  9.  */
  10.  
  11.  
  12.  
  13. var locales, dtfProps;
  14.  
  15. locales = [
  16.   "en",
  17.   "de",
  18.   "es",
  19.   "jp",
  20.   "ar",
  21.   "fr",
  22.   "ko"
  23. ];
  24.  
  25. dtfProps = {
  26.   weekday:      [ "narrow", "short", "long" ],
  27.   era:          [ "narrow", "short", "long" ],
  28.   year:         [ "2-digit", "numeric" ],
  29.   month:        [ "2-digit", "numeric", "narrow", "short", "long" ],
  30.   day:          [ "2-digit", "numeric" ],
  31.   hour:         [ "2-digit", "numeric" ],
  32.   minute:       [ "2-digit", "numeric" ],
  33.   second:       [ "2-digit", "numeric" ],
  34.   timeZoneName: [ "short", "long" ]
  35. };
  36.  
  37.  
  38. locales.forEach(function( locale ) {
  39.   console.group( locale );
  40.  
  41.   Object.keys( dtfProps ).forEach(function( prop ) {
  42.     var allowables = this[ prop ];
  43.  
  44.     console.group( "\t" + prop );
  45.  
  46.     allowables.forEach(function( allow ) {
  47.       var options = {};
  48.  
  49.  
  50.       options[ prop ] = allow;
  51.  
  52.       console.log( "\t\t" + allow + ": " +
  53.         v8Intl.DateTimeFormat([ locale ], options ).format()
  54.       );
  55.  
  56.     });
  57.  
  58.     console.groupEnd( "\t" + prop );
  59.  
  60.   }, dtfProps );
  61.  
  62.   console.groupEnd( locale );
  63. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top