[Pkg-javascript-commits] [dojo] 01/13: Refs #9366. Fixes underflow bug on 1.3 branch. !strict

David Prévot taffit at moszumanska.debian.org
Mon May 11 20:12:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.3.2
in repository dojo.

commit 3da38f037604fb5b99bc0280e65f5f47a3e596cc
Author: Adam Peller <github at peller.org>
Date:   Wed Jun 10 13:47:43 2009 +0000

    Refs #9366.  Fixes underflow bug on 1.3 branch. !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.3/dojo@17831 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 date/locale.js | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/date/locale.js b/date/locale.js
index 339c29f..a7622f6 100644
--- a/date/locale.js
+++ b/date/locale.js
@@ -424,13 +424,24 @@ dojo.date.locale.parse = function(/*String*/value, /*dojo.date.locale.__FormatOp
 
 	// Check for overflow.  The Date() constructor normalizes things like April 32nd...
 	//TODO: why isn't this done for times as well?
-	var allTokens = tokens.join("");
+	var allTokens = tokens.join(""),
+		dateToken = allTokens.indexOf('d') != -1,
+		monthToken = allTokens.indexOf('M') != -1;
+
 	if(!valid ||
-		(allTokens.indexOf('M') != -1 && dateObject.getMonth() != result[1]) ||
-		(allTokens.indexOf('d') != -1 && dateObject.getDate() != result[2])){
+		(monthToken && dateObject.getMonth() > result[1]) ||
+		(dateToken && dateObject.getDate() > result[2])){
 		return null;
 	}
 
+	// Check for underflow, due to DST shifts.  See #9366
+	// This assumes a 1 hour dst shift correction at midnight
+	// We could compare the timezone offset after the shift and add the difference instead.
+	if((monthToken && dateObject.getMonth() < result[1]) ||
+		(dateToken && dateObject.getDate() < result[2])){
+		dateObject = dojo.date.add(dateObject, "hour", 1);
+	}
+
 	return dateObject; // Date
 };
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list