[Pkg-javascript-commits] [dojo] 04/09: Bryan's patch to fix DST problems. Fixes #5047

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


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

taffit pushed a commit to annotated tag 1.0.0rc3
in repository dojo.

commit 707836ac194b83e2f8b968129d5070f81b35cad9
Author: Adam Peller <github at peller.org>
Date:   Thu Nov 8 15:01:45 2007 +0000

    Bryan's patch to fix DST problems. Fixes #5047
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.0/dojo/trunk@11449 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 date.js       |   2 +-
 tests/date.js | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 223 insertions(+), 1 deletion(-)

diff --git a/date.js b/date.js
index 26c2cfe..9366a96 100644
--- a/date.js
+++ b/date.js
@@ -187,7 +187,7 @@ dojo.date.add = function(/*Date*/date, /*String*/interval, /*int*/amount){
 	}
 
 	if(property){
-		sum["set"+property](sum["get"+property]()+amount);
+		sum["setUTC"+property](sum["getUTC"+property]()+amount);
 	}
 
 	if(fixOvershoot && (sum.getDate() < date.getDate())){
diff --git a/tests/date.js b/tests/date.js
index 480355d..78341ab 100644
--- a/tests/date.js
+++ b/tests/date.js
@@ -482,6 +482,228 @@ function test_date_diff(t){
 	dtA = new Date(2000, 11, 31, 23, 59, 59, 0);
 	dtB = new Date(2001, 0, 1, 0, 0, 0, 0);
 	t.is(1000, dojo.date.difference(dtA, dtB, interv));
+},
+function test_date_add_diff_year(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	
+	interv = "year";
+	dtA = new Date(2005, 11, 27);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2005, 11, 27);
+	dtB = dojo.date.add(dtA, interv, -1);
+	t.is(dojo.date.difference(dtA, dtB, interv), -1);
+	
+	dtA = new Date(2000, 1, 29);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2000, 1, 29);
+	dtB = dojo.date.add(dtA, interv, 5);
+	t.is(dojo.date.difference(dtA, dtB, interv), 5);
+	
+	dtA = new Date(1900, 11, 31);
+	dtB = dojo.date.add(dtA, interv, 30);
+	t.is(dojo.date.difference(dtA, dtB, interv), 30);
+	
+	dtA = new Date(1995, 11, 31);
+	dtB = dojo.date.add(dtA, interv, 35);
+	t.is(dojo.date.difference(dtA, dtB, interv), 35);
+},
+function test_date_add_diff_quarter(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "quarter";
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2000, 1, 29);
+	dtB = dojo.date.add(dtA, interv, 2);
+	t.is(dojo.date.difference(dtA, dtB, interv), 2);
+	
+	dtA = new Date(2000, 1, 29);
+	dtB = dojo.date.add(dtA, interv, 4);
+	t.is(dojo.date.difference(dtA, dtB, interv), 4);
+},
+function test_date_add_diff_month(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "month";
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2000, 0, 31);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2000, 1, 29);
+	dtB = dojo.date.add(dtA, interv, 12);
+	t.is(dojo.date.difference(dtA, dtB, interv), 12);
+},
+function test_date_add_diff_week(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "week";
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+},
+function test_date_add_diff_day(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	var interv = "day";
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2001, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 365);
+	t.is(dojo.date.difference(dtA, dtB, interv), 365);
+	
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, 366);
+	t.is(dojo.date.difference(dtA, dtB, interv), 366);
+	
+	dtA = new Date(2000, 1, 28);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2001, 1, 28);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	dtA = new Date(2000, 2, 1);
+	dtB = dojo.date.add(dtA, interv, -1);
+	t.is(dojo.date.difference(dtA, dtB, interv), -1);
+	
+	dtA = new Date(2001, 2, 1);
+	dtB = dojo.date.add(dtA, interv, -1);
+	t.is(dojo.date.difference(dtA, dtB, interv), -1);
+	
+	dtA = new Date(2000, 0, 1);
+	dtB = dojo.date.add(dtA, interv, -1);
+	t.is(dojo.date.difference(dtA, dtB, interv), -1);
+},
+function test_date_add_diff_weekday(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "weekday";
+	// Sat, Jan 1
+	dtA = new Date(2000, 0, 1);
+	// Should be Mon, Jan 3
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	// Sun, Jan 2
+	dtA = new Date(2000, 0, 2);
+	// Should be Mon, Jan 3
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	
+	// Sun, Jan 2
+	dtA = new Date(2000, 0, 2);
+	// Should be Fri, Jan 7
+	dtB = dojo.date.add(dtA, interv, 5);
+	t.is(dojo.date.difference(dtA, dtB, interv), 5);
+	
+	// Sun, Jan 2
+	dtA = new Date(2000, 0, 2);
+	// Should be Mon, Jan 10
+	dtB = dojo.date.add(dtA, interv, 6);
+	t.is(dojo.date.difference(dtA, dtB, interv), 6);
+	
+	// Mon, Jan 3
+	dtA = new Date(2000, 0, 3);
+	// Should be Mon, Jan 17
+	dtB = dojo.date.add(dtA, interv, 10);
+	t.is(dojo.date.difference(dtA, dtB, interv), 10);
+	
+	// Sat, Jan 8
+	dtA = new Date(2000, 0, 8);
+	// Should be Mon, Jan 3
+	dtB = dojo.date.add(dtA, interv, -5);
+	t.is(dojo.date.difference(dtA, dtB, interv), -5);
+	
+	// Sun, Jan 9
+	dtA = new Date(2000, 0, 9);
+	// Should be Wed, Jan 5
+	dtB = dojo.date.add(dtA, interv, -3);
+	t.is(dojo.date.difference(dtA, dtB, interv), -3);
+	
+	// Sun, Jan 23
+	dtA = new Date(2000, 0, 23);
+	// Should be Fri, Jan 7
+	dtB = dojo.date.add(dtA, interv, -11);
+	t.is(dojo.date.difference(dtA, dtB, interv), -11);
+},
+function test_date_add_diff_hour(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "hour";
+	dtA = new Date(2000, 0, 1, 11);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+
+	dtA = new Date(2001, 9, 28, 0);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+
+	dtA = new Date(2001, 9, 28, 23);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+
+	dtA = new Date(2001, 11, 31, 23);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+},
+function test_date_add_diff_minute(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	interv = "minute";
+	dtA = new Date(2000, 11, 31, 23, 59);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+
+	dtA = new Date(2000, 11, 27, 12, 2);
+	dtB = dojo.date.add(dtA, interv, 60);
+	t.is(dojo.date.difference(dtA, dtB, interv), 60);
+},
+function test_date_add_diff_second(t){
+	var interv = ''; // Interval (e.g., year, month)
+	var dtA = null; // Date to increment
+	var dtB = null; // Expected result date
+	console.debug("second");
+	interv = "second";
+	dtA = new Date(2000, 11, 31, 23, 59, 59);
+	dtB = dojo.date.add(dtA, interv, 1);
+	t.is(dojo.date.difference(dtA, dtB, interv), 1);
+
+	dtA = new Date(2000, 11, 27, 8, 10, 59);
+	dtB = dojo.date.add(dtA, interv, 60);
+	t.is(dojo.date.difference(dtA, dtB, interv), 60);
+	
+	// Test environment JS Date doesn't support millisec?
+	//interv = "millisecond";
+	//
+	//dtA = new Date(2000, 11, 31, 23, 59, 59, 999);
+	//dtB = dojo.date.add(dtA, interv, 1);
+	//t.is(dojo.date.difference(dtA, dtB, interv), 1);
+	//
+	//dtA = new Date(2000, 11, 27, 8, 10, 53, 2);
+	//dtB = dojo.date.add(dtA, interv, 1000);
+	//t.is(dojo.date.difference(dtA, dtB, interv), 1000);
 }
 	]
 );

-- 
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