1 jsworld.Locale = function(properties) {
6 this.frac_digits = properties.frac_digits;
9 // may be empty string/null for currencies with no fractional part
10 if (properties.mon_decimal_point === null || properties.mon_decimal_point == "") {
12 if (this.frac_digits > 0)
13 throw "Error: Undefined mon_decimal_point property";
15 properties.mon_decimal_point = "";
18 if (typeof properties.mon_decimal_point != "string")
19 throw "Error: Invalid/missing mon_decimal_point property";
21 this.mon_decimal_point = properties.mon_decimal_point;
24 if (typeof properties.mon_thousands_sep != "string")
25 throw "Error: Invalid/missing mon_thousands_sep property";
27 this.mon_thousands_sep = properties.mon_thousands_sep;
30 if (typeof properties.mon_grouping != "string")
31 throw "Error: Invalid/missing mon_grouping property";
33 this.mon_grouping = properties.mon_grouping;
36 if (typeof properties.positive_sign != "string")
37 throw "Error: Invalid/missing positive_sign property";
39 this.positive_sign = properties.positive_sign;
42 if (typeof properties.negative_sign != "string")
43 throw "Error: Invalid/missing negative_sign property";
45 this.negative_sign = properties.negative_sign;
48 if (properties.p_cs_precedes !== 0 && properties.p_cs_precedes !== 1)
49 throw "Error: Invalid/missing p_cs_precedes property, must be 0 or 1";
51 this.p_cs_precedes = properties.p_cs_precedes;
54 if (properties.n_cs_precedes !== 0 && properties.n_cs_precedes !== 1)
55 throw "Error: Invalid/missing n_cs_precedes, must be 0 or 1";
57 this.n_cs_precedes = properties.n_cs_precedes;
60 if (properties.p_sep_by_space !== 0 &&
61 properties.p_sep_by_space !== 1 &&
62 properties.p_sep_by_space !== 2)
63 throw "Error: Invalid/missing p_sep_by_space property, must be 0, 1 or 2";
65 this.p_sep_by_space = properties.p_sep_by_space;
68 if (properties.n_sep_by_space !== 0 &&
69 properties.n_sep_by_space !== 1 &&
70 properties.n_sep_by_space !== 2)
71 throw "Error: Invalid/missing n_sep_by_space property, must be 0, 1, or 2";
73 this.n_sep_by_space = properties.n_sep_by_space;
76 if (properties.p_sign_posn !== 0 &&
77 properties.p_sign_posn !== 1 &&
78 properties.p_sign_posn !== 2 &&
79 properties.p_sign_posn !== 3 &&
80 properties.p_sign_posn !== 4)
81 throw "Error: Invalid/missing p_sign_posn property, must be 0, 1, 2, 3 or 4";
83 this.p_sign_posn = properties.p_sign_posn;
86 if (properties.n_sign_posn !== 0 &&
87 properties.n_sign_posn !== 1 &&
88 properties.n_sign_posn !== 2 &&
89 properties.n_sign_posn !== 3 &&
90 properties.n_sign_posn !== 4)
91 throw "Error: Invalid/missing n_sign_posn property, must be 0, 1, 2, 3 or 4";
93 this.n_sign_posn = properties.n_sign_posn;
96 if (typeof properties.int_frac_digits != "number" && properties.int_frac_digits < 0)
97 throw "Error: Invalid/missing int_frac_digits property";
99 this.int_frac_digits = properties.int_frac_digits;
102 if (properties.int_p_cs_precedes !== 0 && properties.int_p_cs_precedes !== 1)
103 throw "Error: Invalid/missing int_p_cs_precedes property, must be 0 or 1";
105 this.int_p_cs_precedes = properties.int_p_cs_precedes;
108 if (properties.int_n_cs_precedes !== 0 && properties.int_n_cs_precedes !== 1)
109 throw "Error: Invalid/missing int_n_cs_precedes property, must be 0 or 1";
111 this.int_n_cs_precedes = properties.int_n_cs_precedes;
114 if (properties.int_p_sep_by_space !== 0 &&
115 properties.int_p_sep_by_space !== 1 &&
116 properties.int_p_sep_by_space !== 2)
117 throw "Error: Invalid/missing int_p_sep_by_spacev, must be 0, 1 or 2";
119 this.int_p_sep_by_space = properties.int_p_sep_by_space;
122 if (properties.int_n_sep_by_space !== 0 &&
123 properties.int_n_sep_by_space !== 1 &&
124 properties.int_n_sep_by_space !== 2)
125 throw "Error: Invalid/missing int_n_sep_by_space property, must be 0, 1, or 2";
127 this.int_n_sep_by_space = properties.int_n_sep_by_space;
130 if (properties.int_p_sign_posn !== 0 &&
131 properties.int_p_sign_posn !== 1 &&
132 properties.int_p_sign_posn !== 2 &&
133 properties.int_p_sign_posn !== 3 &&
134 properties.int_p_sign_posn !== 4)
135 throw "Error: Invalid/missing int_p_sign_posn property, must be 0, 1, 2, 3 or 4";
137 this.int_p_sign_posn = properties.int_p_sign_posn;
140 if (properties.int_n_sign_posn !== 0 &&
141 properties.int_n_sign_posn !== 1 &&
142 properties.int_n_sign_posn !== 2 &&
143 properties.int_n_sign_posn !== 3 &&
144 properties.int_n_sign_posn !== 4)
145 throw "Error: Invalid/missing int_n_sign_posn property, must be 0, 1, 2, 3 or 4";
147 this.int_n_sign_posn = properties.int_n_sign_posn;
152 if (properties == null || typeof properties != "object")
153 throw "Error: Invalid/missing time locale properties";
156 // parse the supported POSIX LC_TIME properties
160 this.abday = this._parseList(properties.abday, 7);
163 throw "Error: Invalid abday property: " + error;