Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 818 lines (788 sloc) 30.489 kb
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
1 <h1>Introduction</h1>
2 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
3 This jQuery plugin enables complex culture-aware number and date parsing and
d06d420 @eric-brechemier Fixed typo in first paragraph: hunderds->hundreds
eric-brechemier authored
4 formatting, including the raw culture information for hundreds of different
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
5 languages and countries, as well as an extensible system for localization.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
6 </p>
7 <ul>
8 <li><a href="#why">Why Globalization</a></li>
9 <li><a href="#what">What is a Culture?</a></li>
10 <li><a href="#cultures">jQuery.cultures</a></li>
11 <li><a href="#culture">jQuery.culture</a></li>
12 <li><a href="#prefer">jQuery.preferCulture</a></li>
13 <li><a href="#find">jQuery.findClosestCulture</a></li>
14 <li><a href="#format">jQuery.format</a></li>
15 <li><a href="#parseInt">jQuery.parseInt</a></li>
16 <li><a href="#parseFloat">jQuery.parseFloat</a></li>
17 <li><a href="#parseDate">jQuery.parseDate</a></li>
18 <li><a href="#localize">jQuery.localize</a></li>
19 <li><a href="#extend">Utilizing and Extending Cultures</a></li>
20 <li><a href="#defining">Defining Culture Information</a></li>
21 <li><a href="#numbers">Number Formatting</a></li>
22 <li><a href="#dates">Date Formatting</a></li>
23 </ul>
24
eb5d9ca Try to get TOC working in github
InfinitiesLoop authored
25 <a name="why"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
26 <h2 id="why">Why Globalization?</h2>
27 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
28 Each language, and the countries that speak that language, have different
29 expectations when it comes to how numbers (including currency and percentages)
30 and dates should appear. Obviously, each language has different names for the
31 days of the week and the months of the year. But they also have different
5bd3edb @eric-brechemier Added missing word in "Why Globalization?"
eric-brechemier authored
32 expectations for the structure of dates, such as what order the day, month and
33 year are in. In number formatting, not only does the character used to
7ccd449 @eric-brechemier Enhanced wording in "Why Globalization?"
eric-brechemier authored
34 deliniate number groupings and the decimal portion differ, but the placement of
35 those characters differ as well.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
36 </p>
37 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
38 A user using an application should be able to read and write dates and numbers
39 in the format they are accustomed to. This plugin makes this possible,
9c6027c @eric-brechemier Enhanced wording in "Why Globalization?" (2nd paragraph)
eric-brechemier authored
40 providing an API to convert user-entered number and date strings -- in their
41 own format -- into actual numbers and dates, and conversely, to format numbers
42 and dates into that string format.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
43 </p>
44
814341d Fix TOC in readme on github
InfinitiesLoop authored
45 <a name="what"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
46 <h2 id="what">What is a Culture?</h2>
47 <p>
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
48 jquery.glob.js defines roughly 350 cultures. Part of the reason for this large
2b9154d @eric-brechemier Enhanced wording in "What is a Culture?" (1st paragraph)
eric-brechemier authored
49 number, besides there being a lot of cultures in the world, is because for
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
50 some languages, expectations differ amoung the countries that speak it.
51 English, for example, is an official language in dozens of countries. Despite
52 the language being English, the expected date formatting still greatly differs
53 between them.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
54 </p>
55 <p>
fc1afaf @eric-brechemier Enhanced wording: "What is a Culture?"
eric-brechemier authored
56 So, it does not seem useful to define cultures by their language alone. Nor
bbd724b @eric-brechemier Fixed grammar in "What is a Culture?"
eric-brechemier authored
57 is it useful to define a culture by its country alone, as many countries have
804fc24 @eric-brechemier Fixed overstatement in "What is a Culture?"
eric-brechemier authored
58 several official languages, spoken by sizable populations. Therefore, cultures
59 are defined as a combination of the language and the country speaking it. Each
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
60 culture is given a unique code that is a combination of an ISO 639 two-letter
61 lowercase culture code for the language, and a two-letter uppercase code for
9cc86ef @eric-brechemier Enhancement in "What is a Culture" (2nd paragraph)
eric-brechemier authored
62 the country or region. For example, "en-US" is the culture code for English in
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
63 the United States.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
64 </p>
65 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
66 Yet, it is perhaps unreasonable to expect application developers to cater to
67 every possible language/country combination perfectly. It is important then to
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
68 define so-called 'neutral' cultures based on each language. These cultures
f19d5ce @eric-brechemier Fixed grammar in "What is a Culture?" (3rd paragraph)
eric-brechemier authored
69 define the most likely accepted set of rules by anyone speaking that language,
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
70 whatever the country. Neutral cultures are defined only by their language code.
71 For example, "es" is the neutral culture for Spanish.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
72 </p>
73
814341d Fix TOC in readme on github
InfinitiesLoop authored
74 <a name="cultures"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
75 <h2 id="cultures">jQuery.cultures</h2>
76 <p>
c0db62a @eric-brechemier Enhanced wording in "jQuery.cultures"
eric-brechemier authored
77 A mapping of culture codes to culture objects. For example, jQuery.cultures.fr
78 is an object representing the complete culture definition for the neutral
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
79 French culture. Note that jquery.glob.js alone only includes an English culture.
c0db62a @eric-brechemier Enhanced wording in "jQuery.cultures"
eric-brechemier authored
80 To get additional cultures, you must seperately reference one or more of the
5cc0b31 @eric-brechemier Added clarification in "jQuery.cultures"
eric-brechemier authored
81 culture scripts that come with it. You can see in the section
82 <a href="#defining">Defining Culture Information</a> below which fields are
83 defined in each culture.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
84 </p>
85
814341d Fix TOC in readme on github
InfinitiesLoop authored
86 <a name="culture"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
87 <h2 id="culture">jQuery.culture</h2>
88 <p>
12503bf @eric-brechemier Clarification of the default culture
eric-brechemier authored
89 This property is set to the culture currently selected. An optional culture can
90 be specified for the various parsing and formatting functions; it defaults to
91 jQuery.culture when omitted. To change the current culture, set it to one of
92 the available cultures, for example:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
93 <pre>
72df551 default culture is named default
InfinitiesLoop authored
94 jQuery.culture = jQuery.cultures["fr-FR"];
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
95 </pre>
96 </p>
97
814341d Fix TOC in readme on github
InfinitiesLoop authored
98 <a name="prefer"></a>
61a204a @eric-brechemier Added missing parameter (name) for preferCulture/findClosestCulture
eric-brechemier authored
99 <h2 id="prefer">jQuery.preferCulture(name)</h2>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
100 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
101 An application that supports globalization and/or localization will need to
102 have a way to determine the user's preference. Attempting to automatically
103 determine the appropriate culture is useful, but it is good practice to always
104 offer the user a choice, by whatever means.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
105 </p>
106 <p>
e9cd01e @eric-brechemier Enhanced wording in "jQuery.preferCulture" (2nd paragraph)
eric-brechemier authored
107 Whatever your mechanism, it is likely that you will have to correlate the
5df6e1d @eric-brechemier Enhanced wording in "jQuery.preferCulture" (2nd paragraph)
eric-brechemier authored
108 user's preferences with the list of cultures supported in the app. This
210befd @eric-brechemier Clarification in "jQuery.preferCulture" (2nd paragraph)
eric-brechemier authored
109 function allows you to select the best match given the culture scripts that you
110 have included and to set the jQuery.culture property to the culture which the
111 user prefers.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
112 </p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
113 <p>
3f3c5e2 @eric-brechemier Clarification in "jQuery.preferCulture" (3rd paragraph)
eric-brechemier authored
114 If you pass an array of names instead of a single name string, the first
115 culture for which there is a match (that culture's script has been referenced)
116 will be used. If none match, the search restarts using the corresponding
117 neutral cultures. For example, if the application has included only the neutral
118 "fr" culture, any of these would select it:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
119 <pre>
120 jQuery.preferCulture("fr");
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
121 alert(jQuery.culture.name) // "fr"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
122
123 jQuery.preferCulture("fr-FR");
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
124 alert(jQuery.culture.name) // "fr"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
125
126 jQuery.preferCulture(["es-MX", "fr-FR"]);
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
127 alert(jQuery.culture.name) // "fr"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
128 </pre>
129
12503bf @eric-brechemier Clarification of the default culture
eric-brechemier authored
130 In any case, if no match is found the neutral English culture "en" is selected
131 by default.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
132 </p>
d59ee1f Documented new quality setting support.
InfinitiesLoop authored
133 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
134 Each culture string may also follow the pattern defined in
135 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4"
136 >RFC2616 sec 14.4</a>. That is, a culture name may include a 'quality' value
2cf3a48 @eric-brechemier Reworded for clarification in "jQuery.preferCulture"
eric-brechemier authored
137 that indicates an estimate of the user's preference for the language.
d59ee1f Documented new quality setting support.
InfinitiesLoop authored
138
139 <pre>
140 jQuery.preferCulture("fr;q=0.4, es;q=0.5, he");
141 </pre>
237b556 @eric-brechemier Added language description for clarification in "jQuery.preferCulture"
eric-brechemier authored
142 In this example, the neutral Hebrew culture "he" is given top priority (an
143 unspecified quality is equal to 1). If that language is not an exact match for
76d99e9 @eric-brechemier Replaced "available on" with "available in"
eric-brechemier authored
144 any of the cultures available in jQuery.cultures, then "es" is the next highest
237b556 @eric-brechemier Added language description for clarification in "jQuery.preferCulture"
eric-brechemier authored
145 priority with 0.5, etc. If none of these match, just like with the array syntax,
146 the search starts over and the same rules are applied to the corresponding
147 neutral language culture for each. If still none match, the neutral English
148 culture "en" is used.
d59ee1f Documented new quality setting support.
InfinitiesLoop authored
149 </p>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
150
814341d Fix TOC in readme on github
InfinitiesLoop authored
151 <a name="find"></a>
61a204a @eric-brechemier Added missing parameter (name) for preferCulture/findClosestCulture
eric-brechemier authored
152 <h2 id="find">jQuery.findClosestCulture(name)</h2>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
153 <p>
fb27135 @eric-brechemier Fixed and clarified "jQuery.findClosestCulture"
eric-brechemier authored
154 Just like preferCulture(name), but it just returns the matching culture, if
155 any, without setting it to the jQuery.culture property.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
156 </p>
157
814341d Fix TOC in readme on github
InfinitiesLoop authored
158 <a name="format"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
159 <h2 id="format">jQuery.format(value, format, culture)</h2>
160 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
161 Formats a date or number according to the given format string and the given
e7dd0a6 @eric-brechemier Added links to referenced sections in "jQuery.format"
eric-brechemier authored
162 culture (or the current culture if not specified). See the sections
163 <a href="#numbers">Number Formatting</a> and
164 <a href="#dates">Date Formatting</a> below for details on the available
165 formats.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
166 <pre>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
167 // assuming a culture with number grouping of 3 digits,
168 // using "," separator and "." decimal symbol.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
169 jQuery.format(1234.567, "n"); // "1,234.57"
170 jQuery.format(1234.567, "n1"); // "1,234.6"
171 jQuery.format(1234.567, "n0"); // "1,235"
172
173 // assuming a culture with "/" as the date separator symbol
174 jQuery.format(new Date(1955,10,5), "yyyy/MM/dd"); // 1955/11/05
175 jQuery.format(new Date(1955,10,5), "dddd MMMM d, yyyy"); // Saturday November 5, 1955
176 </pre>
177 </p>
178
814341d Fix TOC in readme on github
InfinitiesLoop authored
179 <a name="parseInt"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
180 <h2 id="parseInt">jQuery.parseInt(value, radix, culture)</h2>
181 <p>
73964c8 @eric-brechemier Removed extra word "the" in "jQuery.parseInt" and "jQuery.parseFloat"
eric-brechemier authored
182 Parses a string representing a whole number in the given radix (10 by default),
183 taking into account any formatting rules followed by the given culture (or the
184 current culture, if not specified).
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
185 <pre>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
186 // assuming a culture where "," is the group separator
187 // and "." is the decimal separator
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
188 jQuery.parseInt("1,234.56"); // 1234
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
189 // assuming a culture where "." is the group separator
190 // and "," is the decimal separator
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
191 jQuery.parseInt("1.234,56"); // 1234
192 </pre>
193 </p>
194
814341d Fix TOC in readme on github
InfinitiesLoop authored
195 <a name="parseFloat"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
196 <h2 id="parseFloat">jQuery.parseFloat(value, radix, culture)</h2>
197 <p>
73964c8 @eric-brechemier Removed extra word "the" in "jQuery.parseInt" and "jQuery.parseFloat"
eric-brechemier authored
198 Parses a string representing a floating point number in the given radix (10 by
199 default), taking into account any formatting rules followed by the given
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
200 culture (or the current culture, if not specified).
187f0b2 @eric-brechemier Added example in "jQuery.paserFloat"
eric-brechemier authored
201 <pre>
202 // assuming a culture where "," is the group separator
203 // and "." is the decimal separator
204 jQuery.parseFloat("1,234.56"); // 1234.56
205 // assuming a culture where "." is the group separator
206 // and "," is the decimal separator
207 jQuery.parseFloat("1.234,56"); // 1234.56
208 </pre>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
209 </p>
210
2e4f0f0 @eric-brechemier Added missing HTML anchor for parseDate
eric-brechemier authored
211 <a name="parseDate"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
212 <h2>jQuery.parseDate(value, formats, culture)</h2>
213 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
214 Parses a string representing a date into a JavaScript Date object, taking into
215 account the given possible formats (or the given culture's set of default
216 formats if not given). As before, the current culture is used if one is not
217 specified.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
218 <pre>
219 jQuery.culture = jQuery.culture.en;
220 jQuery.parseDate("1/2/2003"); // Thu Jan 02 2003
221 jQuery.culture = jQuery.culture.fr;
222 jQuery.parseDate("1/2/2003"); // Sat Feb 01 2003
223 </pre>
224 </p>
225
814341d Fix TOC in readme on github
InfinitiesLoop authored
226 <a name="localize"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
227 <h2 id="localize">jQuery.localize(key, culture, value)</h2>
228 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
229 Gets or sets a localized value. This function allows you to extend the
230 information available to a particular culture, and to easily retrieve it
231 without worrying about finding the most appropriate culture. For example, to
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
232 define the word 'translate' in French:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
233 <pre>
234 jQuery.localize("translate", "fr", "traduire");
235 </pre>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
236 The value may be any value you wish -- a string, number, object, etc. You can
237 then define a grouping of localized values common to a feature, plugin, or
238 application.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
239 <pre>
240 jQuery.localize("myplugin", "fr", {
241 foo: "foo",
242 bar: "bar"
243 });
244
245 var obj = jQuery.localize("myplugin", "fr");
246 alert(obj.foo); // "foo"
247 </pre>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
248 Note that localize() will find the closest match available per the same
13db07f @eric-brechemier Minor clarification in "jQuery.localize" (3rd paragraph)
eric-brechemier authored
249 semantics as the jQuery.findClosestCulture() function. If there is no match,
250 the translation given is for the neutral English culture "en" by default.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
251 <pre>
cdea4eb @eric-brechemier Added comment to clarify 3rd code sample in "jQuery.localize"
eric-brechemier authored
252 jQuery.localize("myplugin", "", { // falsy values "", null, undefined...
253 // are all equivalent to "en" or "default"
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
254 foo: "foo (en)",
255 bar: "bar (en)"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
256 });
257 jQuery.localize("myplugin", "fr", {
6131939 @eric-brechemier Added (fr) in French values in 3rd code sample of "jQuery.localize"
eric-brechemier authored
258 foo: "foo (fr)",
259 bar: "bar (fr)"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
260 });
261
262 jQuery.culture = jQuery.cultures["fr"];
6131939 @eric-brechemier Added (fr) in French values in 3rd code sample of "jQuery.localize"
eric-brechemier authored
263 alert(jQuery.localize("myplugin").foo); // "foo (fr)"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
264
265 jQuery.culture = jQuery.cultures["fr-FR"];
6131939 @eric-brechemier Added (fr) in French values in 3rd code sample of "jQuery.localize"
eric-brechemier authored
266 alert(jQuery.localize("myplugin").foo); // "foo (fr)"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
267
268 jQuery.culture = jQuery.cultures["es-MX"];
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
269 alert(jQuery.localize("myplugin").foo); // "foo (en)"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
270 </pre>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
271 Also note that localize() does not require loading the culture information
272 script. You may use localize() for localization purposes without utilizing the
273 parsing and formatting functions which depend on the cultures. If you do use
274 both, it does not matter what order you include them in, either may be first
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
275 -- the jquery.glob.&lt;code&gt;.js script, or your own script which uses
b6dae70 @eric-brechemier Clarification added at end of "jQuery.localize"
eric-brechemier authored
276 localize(), as long as property names do not overlap.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
277 </p>
278
814341d Fix TOC in readme on github
InfinitiesLoop authored
279 <a name="extend"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
280 <h2 id="extend">Utilizing and Extending Cultures</h2>
281 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
282 The culture information included with each culture is mostly necessary for the
7ab4339 @eric-brechemier Removed duplicate words
eric-brechemier authored
283 parsing and formatting methods, but not all of it. For example, the Native and
284 English names for each culture is given, as well as a boolean indicating
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
285 whether the language is right-to-left. This may be useful information for your
286 own purposes. You may also add to the culture information directly if so
287 desired. It is important to do so in a way that handles the fact that the
288 culture info may not be provided, may not be provided yet, or may already be
289 provided. Using jQuery's extend() method, it is possible to define a culture
45c5c30 @eric-brechemier Added missing word in "Utilizing and Extending Cultures" (1st paragraph"
eric-brechemier authored
290 in a way that both defines it if it does not exist and adds to it if it does
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
291 exist.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
292 </p>
293 <p>
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
294 As an example, in the U.S., the word 'billion' means the number 1,000,000,000
295 (9 zeros). But in other countries, that number is '1000 million' or a
296 'milliard', and a billion is 1,000,000,000,000 (12 zeros). If you needed to
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
297 provide functionality to your app or custom plugin that needed to know how many
298 zeros are in a 'billion', you could extend the culture information as follows:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
299 <pre>
300 // define culture information without overwriting any existing values
301 jQuery.cultures.fr = jQuery.extend(true, {
302 numberFormat: {
303 billionZeros: 12
304 }
305 }, jQuery.cultures.fr);
306 </pre>
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
307 Using this mechanism, the "fr" culture will be created if it does not exist.
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
308 And if it does, the given values will be added to it, taking care not to
309 overwrite anything that is already defined (if you'd prefer to overwrite, you'd
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
310 switch the last two arguments). When the jquery.glob.fr.js script is eventually
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
311 included, it too uses this technique, ensuring addition to the already-defined
312 culture information.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
313 </p>
314
814341d Fix TOC in readme on github
InfinitiesLoop authored
315 <a name="defining"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
316 <h2 id="defining">Defining Culture Information</h2>
317 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
318 Each culture is defined in its own script with the naming scheme
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
319 jquery.glob.&lt;code&gt;.js (along with its minified version,
320 jquery.glob.&lt;code&gt;.min.js). You may include any number of these scripts,
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
321 making them available in the jQuery.cultures mapping. Including one of these
12503bf @eric-brechemier Clarification of the default culture
eric-brechemier authored
322 scripts does NOT automatically make it the current culture selected in the
323 jQuery.culture property.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
324 </p>
325 <p>
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
326 The neutral English culture is defined directly in jquery.glob.js, and set
12503bf @eric-brechemier Clarification of the default culture
eric-brechemier authored
327 both to the properties "en" and "default" of the jQuery.cultures mapping.
8dd11bc @eric-brechemier Completed clarification of default culture in "Defining Culture..."
eric-brechemier authored
328 Extensive comments describe the purpose of each of the fields defined.
329 </p>
330 <p>
331 Looking at the souce code of the scripts for each culture, you will notice
332 that each script uses jQuery's $.extend to copy the properties of the neutral
333 English culture "en", as a common basis, and defines only the properties that
334 differ from neutral English.
335 </p>
336 <p>
337 The neutral English culture is listed here along with the comments:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
338 <pre>
d65bdbd @eric-brechemier Replaced 'default' with "default" in code in "Defining Culture..."
eric-brechemier authored
339 jQuery.cultures["default"] = jQuery.cultures.en = {
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
340 // A unique name for the culture in the form
b055cb9 @eric-brechemier Fixed typo in code sample of "Defining Culture Information"
eric-brechemier authored
341 // &lt;language code&gt;-&lt;country/region code&gt;
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
342 name: "English",
fc09659 @eric-brechemier Capitalized 'English' language in comment
eric-brechemier authored
343 // the name of the culture in the English language
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
344 englishName: "English",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
345 // the name of the culture in its own language
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
346 nativeName: "English",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
347 // whether the culture uses right-to-left text
348 isRTL: false,
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
349 // "language" is used for so-called 'specific' cultures.
350 // For example, the culture "es-CL" means Spanish in Chili.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
351 // It represents the Spanish-speaking culture as it is in Chili,
352 // which might have different formatting rules or even translations
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
353 // than Spanish in Spain. A 'neutral' culture is one that is not
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
354 // specific to a region. For example, the culture "es" is the generic
355 // Spanish culture, which may be a more generalized version of the language
356 // that may or may not be what a specific culture expects.
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
357 // For a specific culture like "es-CL", the "language" field refers to the
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
358 // neutral, generic culture information for the language it is using.
359 // This is not always a simple matter of the string before the dash.
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
360 // For example, the "zh-Hans" culture is neutral (Simplified Chinese).
361 // And the "zh-SG" culture is Simplified Chinese in Singapore, whose
362 // language field is "zh-CHS", not "zh".
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
363 // This field should be used to navigate from a specific culture to it's
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
364 // more general, neutral culture. If a culture is already as general as it
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
365 // can get, the language may refer to itself.
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
366 language: "en",
33c7742 @eric-brechemier Added quotes around property names in code sample in "Defining Culture.....
eric-brechemier authored
367 // "numberFormat" defines general number formatting rules, like the digits
368 // in each grouping, the group separator, and how negative numbers are
369 // displayed.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
370 numberFormat: {
371 // [negativePattern]
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
372 // Note, numberFormat.pattern has no 'positivePattern' unlike percent
373 // and currency, but is still defined as an array for consistency with
374 // them.
375 // negativePattern: one of "(n)|-n|- n|n-|n -"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
376 pattern: ["-n"],
377 // number of decimal places normally shown
378 decimals: 2,
379 // string that separates number groups, as in 1,000,000
380 ',': ",",
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
381 // string that separates a number from the fractional portion,
382 // as in 1.99
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
383 '.': ".",
384 // array of numbers indicating the size of each number group.
385 groupSizes: [3],
386 // symbol used for positive numbers
387 '+': "+",
388 // symbol used for negative numbers
389 '-': "-",
390 percent: {
391 // [negativePattern, positivePattern]
392 // negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
393 // positivePattern: one of "n %|n%|%n|% n"
394 pattern: ["-n %","n %"],
395 // number of decimal places normally shown
396 decimals: 2,
397 // array of numbers indicating the size of each number group.
398 groupSizes: [3],
399 // string that separates number groups, as in 1,000,000
400 ',': ",",
401 // string that separates a number from the fractional portion, as in 1.99
402 '.': ".",
403 // symbol used to represent a percentage
404 symbol: "%"
405 },
406 currency: {
407 // [negativePattern, positivePattern]
408 // negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)"
409 // positivePattern: one of "$n|n$|$ n|n $"
410 pattern: ["($n)","$n"],
411 // number of decimal places normally shown
412 decimals: 2,
413 // array of numbers indicating the size of each number group.
414 groupSizes: [3],
415 // string that separates number groups, as in 1,000,000
416 ',': ",",
417 // string that separates a number from the fractional portion, as in 1.99
418 '.': ".",
419 // symbol used to represent currency
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
420 symbol: "$"
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
421 }
422 },
33c7742 @eric-brechemier Added quotes around property names in code sample in "Defining Culture.....
eric-brechemier authored
423 // "calendars" property defines all the possible calendars used by this
605a518 @eric-brechemier Wording enhancement in "Defining Culture Information" (code sample)
eric-brechemier authored
424 // culture. There should be at least one defined with name "standard" which
33c7742 @eric-brechemier Added quotes around property names in code sample in "Defining Culture.....
eric-brechemier authored
425 // is the default calendar used by the culture.
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
426 // A calendar contains information about how dates are formatted,
427 // information about the calendar's eras, a standard set of the date
428 // formats, translations for day and month names, and if the calendar is
429 // not based on the Gregorian calendar, conversion functions to and from
430 // the Gregorian calendar.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
431 calendars: {
432 standard: {
433 // name that identifies the type of calendar this is
434 name: "Gregorian_USEnglish",
435 // separator of parts of a date (e.g. '/' in 11/05/1955)
436 '/': "/",
437 // separator of parts of a time (e.g. ':' in 05:44 PM)
438 ':': ":",
439 // the first day of the week (0 = Sunday, 1 = Monday, etc)
440 firstDay: 0,
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
441 days: {
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
442 // full day names
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
443 names: ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
444 // abbreviated day names
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
445 namesAbbr: ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
446 // shortest day names
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
447 namesShort: ["Su","Mo","Tu","We","Th","Fr","Sa"]
448 },
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
449 months: [
450 // full month names (13 months for lunar calendars -- 13th month should be "" if not lunar)
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
451 names: ["January","February","March","April","May","June","July","August","September","October","November","December",""],
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
452 // abbreviated month names
10e570f Use named fields for days and months versions. Updated readme and demo.
InfinitiesLoop authored
453 namesAbbr: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",""]
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
454 ],
455 // AM and PM designators in one of these forms:
456 // The usual view, and the upper and lower case versions
457 // [standard,lowercase,uppercase]
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
458 // The culture does not use AM or PM (likely all standard date
459 // formats use 24 hour time)
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
460 // null
461 AM: ["AM", "am", "AM"],
462 PM: ["PM", "pm", "PM"],
463 eras: [
464 // eras in reverse chronological order.
465 // name: the name of the era in this culture (e.g. A.D., C.E.)
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
466 // start: when the era starts in ticks, null if it is the
467 // earliest supported era.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
468 // offset: offset in years from gregorian calendar
469 {"name":"A.D.","start":null,"offset":0}
470 ],
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
471 // when a two digit year is given, it will never be parsed as a
472 // four digit year greater than this year (in the appropriate era
473 // for the culture)
474 // Set it as a full year (e.g. 2029) or use an offset format
475 // starting from the current year: "+19" would correspond to 2029
9d74dec @eric-brechemier Added missing word in "Defining Culture Information" (code sample)
eric-brechemier authored
476 // if the current year is 2010.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
477 twoDigitYearMax: 2029,
d9f0280 @eric-brechemier Added missing period in "Defining Culture Information" (code sample).
eric-brechemier authored
478 // set of predefined date and time patterns used by the culture.
479 // These represent the format someone in this culture would expect
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
480 // to see given the portions of the date that are shown.
481 patterns: {
482 // short date pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
483 d: "M/d/yyyy",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
484 // long date pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
485 D: "dddd, MMMM dd, yyyy",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
486 // short time pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
487 t: "h:mm tt",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
488 // long time pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
489 T: "h:mm:ss tt",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
490 // long date, short time pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
491 f: "dddd, MMMM dd, yyyy h:mm tt",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
492 // long date, long time pattern
099e13a Removed invariant culture. 'en' is the default now.
InfinitiesLoop authored
493 F: "dddd, MMMM dd, yyyy h:mm:ss tt",
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
494 // month/day pattern
495 M: "MMMM dd",
496 // month/year pattern
497 Y: "yyyy MMMM",
498 // S is a sortable format that does not vary by culture
499 S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss"
500 }
501 // optional fields for each calendar:
502 /*
503 monthsGenitive:
504 Same as months but used when the day preceeds the month.
505 Omit if the culture has no genitive distinction in month names.
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
506 For an explanation of genitive months, see
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
507 http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
508 convert:
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
509 Allows for the support of non-gregorian based calendars. This
eb6eead @eric-brechemier Enhanced wording in "Defining Culture Information" (code sample)
eric-brechemier authored
510 "convert" object defines two functions to convert a date to and
511 from a gregorian calendar date:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
512 fromGregorian(date)
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
513 Given the date as a parameter, return an array with
514 parts [year, month, day] corresponding to the
515 non-gregorian based year, month, and day for the
516 calendar.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
517 toGregorian(year, month, day)
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
518 Given the non-gregorian year, month, and day, return a
519 new Date() object set to the corresponding date in the
520 gregorian calendar.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
521 */
522 }
523 }
524 }
525 </pre>
526 </p>
527 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
528 Each culture can have several possible calendars. The calendar named "standard"
529 is the default calendar used by that culture. You may change the calendar in
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
530 use by setting the "calendar" field. Take a look at the calendars defined by
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
531 each culture by looking at the script or enumerating its calendars collection.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
532 <pre>
533 // switch to a non-standard calendar
534 $.culture.calendar = $.culture.calendars.SomeOtherCalendar;
535 // back to the standard calendar
536 $.culture.calendar = $.culture.calendars.standard;
537 </pre>
538
539 </p>
540
814341d Fix TOC in readme on github
InfinitiesLoop authored
541 <a name="numbers"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
542 <h2 id="numbers">Number Formatting</h2>
543 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
544 When formatting a number with format(), the main purpose is to convert the
545 number into a human readable string using the culture's standard grouping and
546 decimal rules. The rules between cultures can vary a lot. For example, in some
547 cultures, the grouping of numbers is done unevenly. In the "te-IN" culture
548 (Telugu in India), groups have 3 digits and then 2 digits. The number 1000000
549 (one million) is written as "10,00,000". Some cultures do not group numbers at
550 all.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
551 </p>
552 <p>
553 There are four main types of number formatting:
554 <ul>
555 <li><strong>n</strong> for number</li>
556 <li><strong>d</strong> for decimal digits</li>
557 <li><strong>p</strong> for percentage</li>
558 <li><strong>c</strong> for currency</li>
559 </ul>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
560 Even within the same culture, the formatting rules can vary between these four
561 types of numbers. For example, the expected number of decimal places may differ
562 from the number format to the currency format. Each format token may also be
2a744d1 @eric-brechemier Removed extra s in "Number Formatting"
eric-brechemier authored
563 followed by a number. The number determines how many decimal places to display
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
564 for all the format types except decimal, for which it means the minimum number
565 of digits to display, zero padding it if necessary. Also note that the way
566 negative numbers are represented in each culture can vary, such as what the
567 negative sign is, and whether the negative sign appears before or after the
568 number. This is especially apparent with currency formatting, where many
569 cultures use parentheses instead of a negative sign.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
570 <pre>
571 // just for example -- will vary by culture
572 jQuery.format(123.45, "n"); // 123.45
573 jQuery.format(123.45, "n0"); // 123
574 jQuery.format(123.45, "n1"); // 123.5
575
576 jQuery.format(123.45, "d"); // 123
577 jQuery.format(12, "d3"); // 012
578
579 jQuery.format(123.45, "c"); // $123.45
580 jQuery.format(123.45, "c0"); // $123
581 jQuery.format(123.45, "c1"); // $123.5
582 jQuery.format(-123.45, "c"); // ($123.55)
583
584 jQuery.format(0.12345, "p"); // 12.35 %
585 jQuery.format(0.12345, "p0"); // 12 %
586 jQuery.format(0.12345, "p4"); // 12.3450 %
587 </pre>
588 Parsing with parseInt and parseFloat also accepts any of these formats.
589 </p>
590
814341d Fix TOC in readme on github
InfinitiesLoop authored
591 <a name="dates"></a>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
592 <h2 id="dates">Date Formatting</h2>
593 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
594 Date formatting varies wildly by culture, not just in the spelling of month and
595 day names, and the date separator, but by the expected order of the various
596 date components, whether to use a 12 or 24 hour clock, and how months and days
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
597 are abbreviated. Many cultures even include "genitive" month names, which are
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
598 different from the typical names and are used only in certain cases.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
599 </p>
600 <p>
30ee5ea @eric-brechemier Updated for more consistent use of single and double quotes
eric-brechemier authored
601 Also, each culture has a set of 'standard' or 'typical' formats. For example,
73442a1 @eric-brechemier Added/removed quotes in "Date Formatting"
eric-brechemier authored
602 in "en-US", when displaying a date in its fullest form, it looks like
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
603 "Saturday, November 05, 1955". Note the non-abbreviated day and month name, the
8ee917c @eric-brechemier Fixed case of file names cited in README
eric-brechemier authored
604 zero padded date, and four digit year. So, jquery.glob.js defines a certain set
73442a1 @eric-brechemier Added/removed quotes in "Date Formatting"
eric-brechemier authored
605 of 'standard' formatting strings for dates that are aliases to the specific
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
606 formats for the culture. See the 2nd table below for the meaning of each token
73442a1 @eric-brechemier Added/removed quotes in "Date Formatting"
eric-brechemier authored
607 in the "en-US" examples.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
608 <table>
609 <tr>
610 <th>Token</th>
611 <th>Meaning</th>
612 <th>en-US (example)</th>
613 </tr>
614 <tr>
615 <td>f</td>
616 <td>Long Date, Short Time</td>
617 <td>dddd, MMMM dd, yyyy h:mm tt</td>
618 </tr>
619 <tr>
620 <td>F</td>
621 <td>Long Date, Long Time</td>
622 <td>dddd, MMMM dd, yyyy h:mm:ss tt</td>
623 </tr>
624 <tr>
625 <td>t</td>
626 <td>Short Time</td>
627 <td>h:mm tt</td>
628 </tr>
629 <tr>
630 <td>T</td>
631 <td>Long Time</td>
632 <td>h:mm:ss tt</td>
633 </tr>
634 <tr>
635 <td>d</td>
636 <td>Short Date</td>
637 <td>M/d/yyyy</td>
638 </tr>
639 <tr>
640 <td>D</td>
641 <td>Long Date</td>
642 <td>dddd, MMMM dd, yyyy</td>
643 </tr>
644 <tr>
645 <td>Y</td>
646 <td>Month/Year</td>
647 <td>MMMM, yyyy</td>
648 </tr>
649 <tr>
650 <td>M</td>
651 <td>Month/Day</td>
652 <td>yyyy MMMM</td>
653 </tr>
654 </table>
655 </p>
656 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
657 In addition to these standard formats, there is the 'S' format. This is a
658 sortable format that is always the same for every culture:
659 <strong>yyyy'-'MM'-'dd'T'HH':'mm':'ss</strong>.
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
660 </p>
661 <p>
8faf830 @eric-brechemier Reformatted comment lines to fit in 80 character width
eric-brechemier authored
662 When more specific control is needed over the formatting, you may use any
7ab4339 @eric-brechemier Removed duplicate words
eric-brechemier authored
663 format you wish by specifing the following custom tokens:
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
664 <table>
665 <tr>
666 <th>Token</th>
667 <th>Meaning</th>
668 <th>Example</th>
669 </tr>
670 <tr>
671 <td>d</td>
672 <td>Day of month (no leading zero)</td>
673 <td>5</td>
674 </tr>
675 <tr>
676 <td>dd</td>
677 <td>Day of month (leading zero)</td>
678 <td>05</td>
679 </tr>
680 <tr>
681 <td>ddd</td>
682 <td>Day name (abbreviated)</td>
683 <td>Sat</td>
684 </tr>
685 <tr>
686 <td>dddd</td>
687 <td>Day name (full)</td>
688 <td>Saturday</td>
689 </tr>
690 <tr>
691 <td>M</td>
692 <td>Month of year (no leading zero)</td>
693 <td>9</td>
694 </tr>
695 <tr>
696 <td>MM</td>
697 <td>Month of year (leading zero)</td>
698 <td>09</td>
699 </tr>
700 <tr>
701 <td>MMM</td>
5249f67 @eric-brechemier Fixed various misspellings
eric-brechemier authored
702 <td>Month name (abbreviated)</td>
58240a9 Added ability to specify multiple cultures at once. Added readme. Update...
InfinitiesLoop authored
703 <td>Sept</td>
704 </tr>
705 <tr>
706 <td>MMMM</td>
707 <td>Month name (full)</td>
708 <td>September</td>
709 </tr>
710 <tr>
711 <td>yy</td>
712 <td>Year (two digits)</td>
713 <td>55</td>
714 </tr>
715 <tr>
716 <td>yyyy</td>
717 <td>Year (four digits)</td>
718 <td>1955</td>
719 </tr>
720 <tr>
721 <td>'literal'</td>
722 <td>Literal Text</td>
723 <td>'Hmmmm'...</td>
724 </tr>
725 <tr>
726 <td>\'</td>
727 <td>Single Quote</td>
728 <td>&nbsp;</td>
729 </tr>
730 <tr>
731 <td>m</td>
732 <td>Minutes (no leading zero)</td>
733 <td>9</td>
734 </tr>
735 <tr>
736 <td>mm</td>
737 <td>Minutes (leading zero)</td>
738 <td>09</td>
739 </tr>
740 <tr>
741 <td>h</td>
742 <td>Hours (leading zero)</td>
743 <td>6</td>
744 </tr>
745 <tr>
746 <td>hh</td>
747 <td>Hours (leading zero)</td>
748 <td>06</td>
749 </tr>
750 <tr>
751 <td>H</td>
752 <td>Hours (24 hour time, no leading zero)</td>
753 <td>5 (5am) 15 (3pm)</td>
754 </tr>
755 <tr>
756 <td>HH</td>
757 <td>Hours (24 hour time, leading zero)</td>
758 <td>05 (5am) 15 (3pm)</td>
759 </tr>
760 <tr>
761 <td>s</td>
762 <td>Seconds (no leading zero)</td>
763 <td>9</td>
764 </tr>
765 <tr>
766 <td>ss</td>
767 <td>Seconds (leading zero)</td>
768 <td>09</td>
769 </tr>
770 <tr>
771 <td>f</td>
772 <td>Deciseconds</td>
773 <td>1</td>
774 </tr>
775 <tr>
776 <td>ff</td>
777 <td>Centiseconds</td>
778 <td>11</td>
779 </tr>
780 <tr>
781 <td>fff</td>
782 <td>Milliseconds</td>
783 <td>111</td>
784 </tr>
785 <tr>
786 <td>t</td>
787 <td>AM/PM indicator (first letter)</td>
788 <td>A or P</td>
789 </tr>
790 <tr>
791 <td>tt</td>
792 <td>AM/PM indicator (full)</td>
793 <td>AM or PM</td>
794 </tr>
795 <tr>
796 <td>z</td>
797 <td>Timezone offset (hours only, no leading zero)</td>
798 <td>-8</td>
799 </tr>
800 <tr>
801 <td>zz</td>
802 <td>Timezone offset (hours only, leading zero)</td>
803 <td>-08</td>
804 </tr>
805 <tr>
806 <td>zzz</td>
807 <td>Timezone offset (full hours/minutes)</td>
808 <td>-08:00</td>
809 </tr>
810 <tr>
811 <td>g or gg</td>
812 <td>Era name</td>
813 <td>A.D.</td>
814 </tr>
815 </table>
816 </p>
817
Something went wrong with that request. Please try again.