]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/cldr/supplemental.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojo / cldr / supplemental.js
1 if(!dojo._hasResource["dojo.cldr.supplemental"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojo.cldr.supplemental"] = true;
3 dojo.provide("dojo.cldr.supplemental");
4
5 dojo.require("dojo.i18n");
6
7 dojo.cldr.supplemental.getFirstDayOfWeek = function(/*String?*/locale){
8 // summary: Returns a zero-based index for first day of the week
9 // description:
10 //              Returns a zero-based index for first day of the week, as used by the local (Gregorian) calendar.
11 //              e.g. Sunday (returns 0), or Monday (returns 1)
12
13         // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/firstDay
14         var firstDay = {/*default is 1=Monday*/
15                 mv:5,
16                 ae:6,af:6,bh:6,dj:6,dz:6,eg:6,er:6,et:6,iq:6,ir:6,jo:6,ke:6,kw:6,lb:6,ly:6,ma:6,om:6,qa:6,sa:6,
17                 sd:6,so:6,tn:6,ye:6,
18                 as:0,au:0,az:0,bw:0,ca:0,cn:0,fo:0,ge:0,gl:0,gu:0,hk:0,ie:0,il:0,is:0,jm:0,jp:0,kg:0,kr:0,la:0,
19                 mh:0,mo:0,mp:0,mt:0,nz:0,ph:0,pk:0,sg:0,th:0,tt:0,tw:0,um:0,us:0,uz:0,vi:0,za:0,zw:0,
20                 et:0,mw:0,ng:0,tj:0,
21 // variant. do not use?         gb:0,
22                 sy:4
23         };
24
25         var country = dojo.cldr.supplemental._region(locale);
26         var dow = firstDay[country];
27         return (dow === undefined) ? 1 : dow; /*Number*/
28 };
29
30 dojo.cldr.supplemental._region = function(/*String?*/locale){
31         locale = dojo.i18n.normalizeLocale(locale);
32         var tags = locale.split('-');
33         var region = tags[1];
34         if(!region){
35                 // IE often gives language only (#2269)
36                 // Arbitrary mappings of language-only locales to a country:
37         region = {de:"de", en:"us", es:"es", fi:"fi", fr:"fr", hu:"hu", it:"it",
38         ja:"jp", ko:"kr", nl:"nl", pt:"br", sv:"se", zh:"cn"}[tags[0]];
39         }else if(region.length == 4){
40                 // The ISO 3166 country code is usually in the second position, unless a
41                 // 4-letter script is given. See http://www.ietf.org/rfc/rfc4646.txt
42                 region = tags[2];
43         }
44         return region;
45 }
46
47 dojo.cldr.supplemental.getWeekend = function(/*String?*/locale){
48 // summary: Returns a hash containing the start and end days of the weekend
49 // description:
50 //              Returns a hash containing the start and end days of the weekend according to local custom using locale,
51 //              or by default in the user's locale.
52 //              e.g. {start:6, end:0}
53
54         // from http://www.unicode.org/cldr/data/common/supplemental/supplementalData.xml:supplementalData/weekData/weekend{Start,End}
55         var weekendStart = {/*default is 6=Saturday*/
56                 eg:5,il:5,sy:5,
57                 'in':0,
58                 ae:4,bh:4,dz:4,iq:4,jo:4,kw:4,lb:4,ly:4,ma:4,om:4,qa:4,sa:4,sd:4,tn:4,ye:4              
59         };
60
61         var weekendEnd = {/*default is 0=Sunday*/
62                 ae:5,bh:5,dz:5,iq:5,jo:5,kw:5,lb:5,ly:5,ma:5,om:5,qa:5,sa:5,sd:5,tn:5,ye:5,af:5,ir:5,
63                 eg:6,il:6,sy:6
64         };
65
66         var country = dojo.cldr.supplemental._region(locale);
67         var start = weekendStart[country];
68         var end = weekendEnd[country];
69         if(start === undefined){start=6;}
70         if(end === undefined){end=0;}
71         return {start:start, end:end}; /*Object {start,end}*/
72 };
73
74 }