Reviewed by Darin.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jul 2006 11:45:34 +0000 (11:45 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jul 2006 11:45:34 +0000 (11:45 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5257
        setYear() does not match FireFox/IE behavior

        Make sure the right values end up in tm_year.

        * kjs/date_object.cpp:
        (KJS::formatTime):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15594 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/date_object.cpp
LayoutTests/fast/js/kde/Date-setYear-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/kde/Date-setYear.html [new file with mode: 0644]
LayoutTests/fast/js/kde/resources/Date-setYear.js [new file with mode: 0644]

index c1e5d9c..9fa75ba 100644 (file)
@@ -1,3 +1,15 @@
+2006-07-24  Rob Buis  <buis@kde.org>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5257
+        setYear() does not match FireFox/IE behavior
+
+        Make sure the right values end up in tm_year.
+
+        * kjs/date_object.cpp:
+        (KJS::formatTime):
+
 2006-07-23  Mark Rowe  <opendarwin.org@bdash.net.nz>
 
         Reviewed by Maciej.
index 3363a6d..ce8a61d 100644 (file)
@@ -657,7 +657,7 @@ JSValue *DateProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const
     fillStructuresUsingDateArgs(exec, args, 3, &ms, &t);
     break;
   case SetYear:
-    t.tm_year = args[0]->toInt32(exec) >= 1900 ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
+    t.tm_year = (args[0]->toInt32(exec) > 99 || args[0]->toInt32(exec) < 0) ? args[0]->toInt32(exec) - 1900 : args[0]->toInt32(exec);
     break;
   }
 
diff --git a/LayoutTests/fast/js/kde/Date-setYear-expected.txt b/LayoutTests/fast/js/kde/Date-setYear-expected.txt
new file mode 100644 (file)
index 0000000..acb884a
--- /dev/null
@@ -0,0 +1,19 @@
+KDE JS Test
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Start Of Test
+PASS d.setYear(-1), d.getFullYear() is -1
+PASS d.setYear(0), d.getFullYear() is 1900
+PASS d.setYear(1), d.getFullYear() is 1901
+PASS d.setYear(99), d.getFullYear() is 1999
+PASS d.setYear(100), d.getFullYear() is 100
+PASS d.setYear(2050), d.getFullYear() is 2050
+PASS d.setYear(1899), d.getFullYear() is 1899
+PASS d.setYear(2000), d.getFullYear() is 2000
+PASS d.setYear(2100), d.getFullYear() is 2100
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/kde/Date-setYear.html b/LayoutTests/fast/js/kde/Date-setYear.html
new file mode 100644 (file)
index 0000000..df5b3ed
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../resources/js-test-style.css">
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("KDE JS Test");
+</script>
+<script src="resources/Date-setYear.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/kde/resources/Date-setYear.js b/LayoutTests/fast/js/kde/resources/Date-setYear.js
new file mode 100644 (file)
index 0000000..fe10a18
--- /dev/null
@@ -0,0 +1,14 @@
+debug("Start Of Test");
+
+var d = new Date();
+shouldBe("d.setYear(-1), d.getFullYear()", "-1");
+shouldBe("d.setYear(0), d.getFullYear()", "1900");
+shouldBe("d.setYear(1), d.getFullYear()", "1901");
+shouldBe("d.setYear(99), d.getFullYear()", "1999");
+shouldBe("d.setYear(100), d.getFullYear()", "100");
+shouldBe("d.setYear(2050), d.getFullYear()", "2050");
+shouldBe("d.setYear(1899), d.getFullYear()", "1899");
+shouldBe("d.setYear(2000), d.getFullYear()", "2000");
+shouldBe("d.setYear(2100), d.getFullYear()", "2100");
+
+successfullyParsed = true