Reviewed by Adam.
authorkmccullo <kmccullo@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Oct 2006 00:19:21 +0000 (00:19 +0000)
committerkmccullo <kmccullo@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Oct 2006 00:19:21 +0000 (00:19 +0000)
        - Layout test fix

        * kjs/DateMath.cpp:
        (KJS::dateToDayInYear): accept and correctly handle negative months

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

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/DateMath.cpp

index 40dac3145d4d8d36a20b8477baa92d55210089a8..e5560afe3edc677a9576373a0674088f1fd16f8e 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-04  Kevin McCullough  <KMcCullough@apple.com>
+
+        Reviewed by Adam.
+
+        - Layout test fix
+
+        * kjs/DateMath.cpp:
+        (KJS::dateToDayInYear): accept and correctly handle negative months
+
 2006-10-05  Kevin McCullough  <KMcCullough@apple.com>
 
        build fix
index 787e4bfdbbb1f17b0fc54701a23f640ebf2e2fe4..d6724d7e2f16f58e5c162e07c9370dcdd05c4cd6 100644 (file)
@@ -277,11 +277,13 @@ static inline double timeToMseconds(double hour, double min, double sec, double
 
 static int dateToDayInYear(int year, int month, int day)
 {
-    year += static_cast<int>(floor(month / 12.0));
+    year += month / 12;
 
-    month = static_cast<int>(fmod(month, 12.0));
-    if (month < 0)
+    month %= 12;
+    if (month < 0) {
         month += 12;
+        --year;
+    }
 
     int yearday = static_cast<int>(floor(msFrom1970ToYear(year) / msPerDay));
     int monthday = monthToDayInYear(month, isLeapYear(year));