root / trunk / web / dojo / dojox / date / hebrew / numerals.js @ 12
History | View | Annotate | Download (1.8 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.date.hebrew.numerals"]){ |
9 |
dojo._hasResource["dojox.date.hebrew.numerals"]=true; |
10 |
dojo.provide("dojox.date.hebrew.numerals");
|
11 |
(function(){
|
12 |
var _1="אבגדהוזחט"; |
13 |
var _2="יכלמנסעפצ"; |
14 |
var _3="קרשת"; |
15 |
var _4=function(_5,_6){ |
16 |
_5=_5.replace("יה","טו").replace("יו","טז"); |
17 |
if(!_6){
|
18 |
var _7=_5.length;
|
19 |
if(_7>1){ |
20 |
_5=_5.substr(0,_7-1)+"\""+_5.charAt(_7-1); |
21 |
}else{
|
22 |
_5+="׳";
|
23 |
} |
24 |
} |
25 |
return _5;
|
26 |
}; |
27 |
var _8=function(_9){ |
28 |
var _a=0; |
29 |
dojo.forEach(_9,function(ch){
|
30 |
var i;
|
31 |
if((i=_1.indexOf(ch))!=-1){ |
32 |
_a+=++i; |
33 |
}else{
|
34 |
if((i=_2.indexOf(ch))!=-1){ |
35 |
_a+=10*++i;
|
36 |
}else{
|
37 |
if((i=_3.indexOf(ch))!=-1){ |
38 |
_a+=100*++i;
|
39 |
} |
40 |
} |
41 |
} |
42 |
}); |
43 |
return _a;
|
44 |
}; |
45 |
var _b=function(_c){ |
46 |
var _d="",n=4,j=9; |
47 |
while(_c){
|
48 |
if(_c>=n*100){ |
49 |
_d+=_3.charAt(n-1);
|
50 |
_c-=n*100;
|
51 |
continue;
|
52 |
}else{
|
53 |
if(n>1){ |
54 |
n--; |
55 |
continue;
|
56 |
}else{
|
57 |
if(_c>=j*10){ |
58 |
_d+=_2.charAt(j-1);
|
59 |
_c-=j*10;
|
60 |
}else{
|
61 |
if(j>1){ |
62 |
j--; |
63 |
continue;
|
64 |
}else{
|
65 |
if(_c>0){ |
66 |
_d+=_1.charAt(_c-1);
|
67 |
_c=0;
|
68 |
} |
69 |
} |
70 |
} |
71 |
} |
72 |
} |
73 |
} |
74 |
return _d;
|
75 |
}; |
76 |
dojox.date.hebrew.numerals.getYearHebrewLetters=function(_e){ |
77 |
var _f=_e%1000; |
78 |
return _4(_b(_f));
|
79 |
}; |
80 |
dojox.date.hebrew.numerals.parseYearHebrewLetters=function(_10){ |
81 |
return _8(_10)+5000; |
82 |
}; |
83 |
dojox.date.hebrew.numerals.getDayHebrewLetters=function(day,_11){ |
84 |
return _4(_b(day),_11);
|
85 |
}; |
86 |
dojox.date.hebrew.numerals.parseDayHebrewLetters=function(day){ |
87 |
return _8(day);
|
88 |
}; |
89 |
dojox.date.hebrew.numerals.getMonthHebrewLetters=function(_12){ |
90 |
return _4(_b(_12+1)); |
91 |
}; |
92 |
dojox.date.hebrew.numerals.parseMonthHebrewLetters=function(_13){ |
93 |
var _14=dojox.date.hebrew.numerals.parseDayHebrewLetters(_13)-1; |
94 |
if(_14==-1||_14>12){ |
95 |
throw new Error("The month name is incorrect , month = "+_14); |
96 |
} |
97 |
return _14;
|
98 |
}; |
99 |
})(); |
100 |
} |