From 7a93034e3271b5b7691ebedb76a8d33c2281fbd9 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 31 Aug 2006 00:12:53 +0000 Subject: [PATCH] closes #245, strToDate() should handle "st," "nd" and "rd" suffixes on days closes #246, strToTime() does not handle AD/BC dates with fewer than 4 digits --- chrome/chromeFiles/content/scholar/xpcom/scholar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js index 0ff2d41d1..320de13e9 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/scholar.js +++ b/chrome/chromeFiles/content/scholar/xpcom/scholar.js @@ -661,7 +661,7 @@ Scholar.Date = new function(){ Scholar.debug("DATE: used form 1: SQL"); var jsDate = new Date(m[1], m[2]-1, m[3], false, false, false); } else { // not an sql date - var yearRe = /^((?:circa |around |about |c\.? ?)[0-9]{1,4}(?: ?B\.? ?C\.?(?: ?E\.?)?| ?C\.? ?E\.?| ?A\.? ?D\.?)|[0-9]{4})$/i; + var yearRe = /^[0-9]+$/i; if(yearRe.test(string)) { // is just a year Scholar.debug("DATE: used form 2: year-only"); @@ -685,7 +685,7 @@ Scholar.Date = new function(){ // no javascript date. time for cruder things. // first, see if we have anything resembling a year - var yearRe = /^(.*)\b((?:circa |around |about |c\.? ?)[0-9]{1,4}(?: ?B\.? ?C\.?(?: ?E\.?)?| ?C\.? ?E\.?| ?A\.? ?D\.?)|[0-9]{4})\b(.*)$/i; + var yearRe = /^(.*)\b((?:circa |around |about |c\.? ?)?[0-9]{1,4}(?: ?B\.? ?C\.?(?: ?E\.?)?| ?C\.? ?E\.?| ?A\.? ?D\.?)|[0-9]{3,4})\b(.*)$/i; var m = yearRe.exec(string); if(m) { @@ -705,7 +705,7 @@ Scholar.Date = new function(){ Scholar.debug("DATE: got month ("+date.month+", "+date.part+")"); // then, see if there's a day - var dayRe = /^(.*)\b([0-9]{1,2})\b(.*)$/i; + var dayRe = /^(.*)\b([0-9]{1,2})(?:st|nd|rd|th)?\b(.*)$/i; var m = dayRe.exec(date.part); if(m) { date.day = m[2];