Ticket #815: cite.js-patch

File cite.js-patch, 1.5 KB (added by codec, 9 years ago)

Patch to fix date-part and add ordinal formats

Line 
1Index: cite.js
2===================================================================
3--- cite.js     (revision 1816)
4+++ cite.js     (working copy)
5@@ -927,23 +927,28 @@
6                                                                } else if(part == "month") {
7                                                                        // if month is a numeric month, format as such
8                                                                        if(!isNaN(string*1)) {
9-                                                                               if(form == "numeric-leading-zeros") {
10+                                                                               if(newForm == "numeric-leading-zeros") {
11                                                                                        if(string.length == 1) {
12                                                                                                string = "0" + string;
13                                                                                        }
14-                                                                               } else if(form == "short") {
15+                                                                               } else if(newForm == "short") {
16                                                                                        string = this._terms["short"]["_months"][string];
17-                                                                               } else if(form != "numeric") {
18+                                                                               } else if(newForm != "numeric") {
19                                                                                        string = this._terms["long"]["_months"][string];
20                                                                                }
21                                                                        } else if(form == "numeric") {
22                                                                                string = "";
23                                                                        }
24                                                                } else if(part == "day") {
25-                                                                       if(form == "numeric-leading-zeros"
26-                                                                                       && string.length() == 1) {
27+                                                                       if(newForm == "numeric-leading-zeros"
28+                                                                                       && string.length == 1) {
29                                                                                string = "0" + string;
30                                                                        }
31+                                                                       else if (newForm == "ordinal") {
32+                                                                               var ind = parseInt(string)
33+                                                                               var daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|").split("|");
34+                                                                               string += (parseInt(ind/10)%10) == 1 ? daySuffixes[3] : (ind % 10 == 1) ? daySuffixes[0] : (ind % 10 == 2) ? daySuffixes[1] : (ind % 10 == 3) ? daySuffixes[2] : daySuffixes[3]
35+                                                                       }
36                                                                }
37                                                        }
38                                                }