cldr.supplemental.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * CLDR JavaScript Library v0.4.3
  3. * http://jquery.com/
  4. *
  5. * Copyright 2013 Rafael Xavier de Souza
  6. * Released under the MIT license
  7. * http://jquery.org/license
  8. *
  9. * Date: 2015-08-24T01:00Z
  10. */
  11. /*!
  12. * CLDR JavaScript Library v0.4.3 2015-08-24T01:00Z MIT license © Rafael Xavier
  13. * http://git.io/h4lmVg
  14. */
  15. (function( factory ) {
  16. if ( typeof define === "function" && define.amd ) {
  17. // AMD.
  18. define( [ "../cldr" ], factory );
  19. } else if ( typeof module === "object" && typeof module.exports === "object" ) {
  20. // Node. CommonJS.
  21. module.exports = factory( require( "cldrjs" ) );
  22. } else {
  23. // Global
  24. factory( Cldr );
  25. }
  26. }(function( Cldr ) {
  27. // Build optimization hack to avoid duplicating functions across modules.
  28. var alwaysArray = Cldr._alwaysArray;
  29. var supplementalMain = function( cldr ) {
  30. var prepend, supplemental;
  31. prepend = function( prepend ) {
  32. return function( path ) {
  33. path = alwaysArray( path );
  34. return cldr.get( [ prepend ].concat( path ) );
  35. };
  36. };
  37. supplemental = prepend( "supplemental" );
  38. // Week Data
  39. // http://www.unicode.org/reports/tr35/tr35-dates.html#Week_Data
  40. supplemental.weekData = prepend( "supplemental/weekData" );
  41. supplemental.weekData.firstDay = function() {
  42. return cldr.get( "supplemental/weekData/firstDay/{territory}" ) ||
  43. cldr.get( "supplemental/weekData/firstDay/001" );
  44. };
  45. supplemental.weekData.minDays = function() {
  46. var minDays = cldr.get( "supplemental/weekData/minDays/{territory}" ) ||
  47. cldr.get( "supplemental/weekData/minDays/001" );
  48. return parseInt( minDays, 10 );
  49. };
  50. // Time Data
  51. // http://www.unicode.org/reports/tr35/tr35-dates.html#Time_Data
  52. supplemental.timeData = prepend( "supplemental/timeData" );
  53. supplemental.timeData.allowed = function() {
  54. return cldr.get( "supplemental/timeData/{territory}/_allowed" ) ||
  55. cldr.get( "supplemental/timeData/001/_allowed" );
  56. };
  57. supplemental.timeData.preferred = function() {
  58. return cldr.get( "supplemental/timeData/{territory}/_preferred" ) ||
  59. cldr.get( "supplemental/timeData/001/_preferred" );
  60. };
  61. return supplemental;
  62. };
  63. var initSuper = Cldr.prototype.init;
  64. /**
  65. * .init() automatically ran on construction.
  66. *
  67. * Overload .init().
  68. */
  69. Cldr.prototype.init = function() {
  70. initSuper.apply( this, arguments );
  71. this.supplemental = supplementalMain( this );
  72. };
  73. return Cldr;
  74. }));