]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/cldr/supplemental.js.uncompressed.js
6de6ce7ff2f6b4d7960daf83af5d66f262dfc0cf
[tt-rss.git] / lib / dojo / cldr / supplemental.js.uncompressed.js
1 define("dojo/cldr/supplemental", ["../_base/lang", "../i18n"], function(lang, i18n){
2
3 // module:
4 // dojo/cldr/supplemental
5
6
7 var supplemental = {
8 // summary:
9 // TODOC
10 };
11 lang.setObject("dojo.cldr.supplemental", supplemental);
12
13 supplemental.getFirstDayOfWeek = function(/*String?*/locale){
14 // summary:
15 // Returns a zero-based index for first day of the week
16 // description:
17 // Returns a zero-based index for first day of the week, as used by the local (Gregorian) calendar.
18 // e.g. Sunday (returns 0), or Monday (returns 1)
19
20 // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/firstDay
21 var firstDay = {/*default is 1=Monday*/
22 bd:5,mv:5,
23 ae:6,af:6,bh:6,dj:6,dz:6,eg:6,iq:6,ir:6,jo:6,kw:6,
24 ly:6,ma:6,om:6,qa:6,sa:6,sd:6,sy:6,ye:6,
25 ag:0,ar:0,as:0,au:0,br:0,bs:0,bt:0,bw:0,by:0,bz:0,ca:0,cn:0,
26 co:0,dm:0,'do':0,et:0,gt:0,gu:0,hk:0,hn:0,id:0,ie:0,il:0,'in':0,
27 jm:0,jp:0,ke:0,kh:0,kr:0,la:0,mh:0,mm:0,mo:0,mt:0,mx:0,mz:0,
28 ni:0,np:0,nz:0,pa:0,pe:0,ph:0,pk:0,pr:0,py:0,sg:0,sv:0,th:0,
29 tn:0,tt:0,tw:0,um:0,us:0,ve:0,vi:0,ws:0,za:0,zw:0
30 };
31
32 var country = supplemental._region(locale);
33 var dow = firstDay[country];
34 return (dow === undefined) ? 1 : dow; /*Number*/
35 };
36
37 supplemental._region = function(/*String?*/locale){
38 locale = i18n.normalizeLocale(locale);
39 var tags = locale.split('-');
40 var region = tags[1];
41 if(!region){
42 // IE often gives language only (#2269)
43 // Arbitrary mappings of language-only locales to a country:
44 region = {de:"de", en:"us", es:"es", fi:"fi", fr:"fr", he:"il", hu:"hu", it:"it",
45 ja:"jp", ko:"kr", nl:"nl", pt:"br", sv:"se", zh:"cn"}[tags[0]];
46 }else if(region.length == 4){
47 // The ISO 3166 country code is usually in the second position, unless a
48 // 4-letter script is given. See http://www.ietf.org/rfc/rfc4646.txt
49 region = tags[2];
50 }
51 return region;
52 };
53
54 supplemental.getWeekend = function(/*String?*/locale){
55 // summary:
56 // Returns a hash containing the start and end days of the weekend
57 // description:
58 // Returns a hash containing the start and end days of the weekend according to local custom using locale,
59 // or by default in the user's locale.
60 // e.g. {start:6, end:0}
61
62 // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/weekend{Start,End}
63 var weekendStart = {/*default is 6=Saturday*/
64 'in':0,
65 af:4,dz:4,ir:4,om:4,sa:4,ye:4,
66 ae:5,bh:5,eg:5,il:5,iq:5,jo:5,kw:5,ly:5,ma:5,qa:5,sd:5,sy:5,tn:5
67 },
68
69 weekendEnd = {/*default is 0=Sunday*/
70 af:5,dz:5,ir:5,om:5,sa:5,ye:5,
71 ae:6,bh:5,eg:6,il:6,iq:6,jo:6,kw:6,ly:6,ma:6,qa:6,sd:6,sy:6,tn:6
72 },
73
74 country = supplemental._region(locale),
75 start = weekendStart[country],
76 end = weekendEnd[country];
77
78 if(start === undefined){start=6;}
79 if(end === undefined){end=0;}
80 return {start:start, end:end}; /*Object {start,end}*/
81 };
82
83 return supplemental;
84 });