Title: [124095] trunk/Source/WTF
- Revision
- 124095
- Author
- par...@webkit.org
- Date
- 2012-07-30 14:53:03 -0700 (Mon, 30 Jul 2012)
Log Message
Add function to calculate the day in year from a date
https://bugs.webkit.org/show_bug.cgi?id=92671
Reviewed by Ryosuke Niwa.
Replace monthToDayInYear() with dayInYear() which takes a whole
date for calculation and will be used for bug 92286 later.
* wtf/DateMath.cpp:
(WTF::dayInYear):
(WTF::dateToDaysFrom1970):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (124094 => 124095)
--- trunk/Source/WTF/ChangeLog 2012-07-30 21:35:10 UTC (rev 124094)
+++ trunk/Source/WTF/ChangeLog 2012-07-30 21:53:03 UTC (rev 124095)
@@ -1,5 +1,19 @@
2012-07-30 Patrick Gansterer <par...@webkit.org>
+ Add function to calculate the day in year from a date
+ https://bugs.webkit.org/show_bug.cgi?id=92671
+
+ Reviewed by Ryosuke Niwa.
+
+ Replace monthToDayInYear() with dayInYear() which takes a whole
+ date for calculation and will be used for bug 92286 later.
+
+ * wtf/DateMath.cpp:
+ (WTF::dayInYear):
+ (WTF::dateToDaysFrom1970):
+
+2012-07-30 Patrick Gansterer <par...@webkit.org>
+
Add special export macro for string related functions
https://bugs.webkit.org/show_bug.cgi?id=92624
Modified: trunk/Source/WTF/wtf/DateMath.cpp (124094 => 124095)
--- trunk/Source/WTF/wtf/DateMath.cpp 2012-07-30 21:35:10 UTC (rev 124094)
+++ trunk/Source/WTF/wtf/DateMath.cpp 2012-07-30 21:53:03 UTC (rev 124095)
@@ -286,9 +286,9 @@
return d - step;
}
-static inline int monthToDayInYear(int month, bool isLeapYear)
+static inline int dayInYear(int year, int month, int day)
{
- return firstDayOfMonth[isLeapYear][month];
+ return firstDayOfMonth[isLeapYear(year)][month] + day - 1;
}
double dateToDaysFrom1970(int year, int month, int day)
@@ -303,9 +303,7 @@
double yearday = floor(daysFrom1970ToYear(year));
ASSERT((year >= 1970 && yearday >= 0) || (year < 1970 && yearday < 0));
- int monthday = monthToDayInYear(month, isLeapYear(year));
-
- return yearday + monthday + day - 1;
+ return yearday + dayInYear(year, month, day);
}
// There is a hard limit at 2038 that we currently do not have a workaround
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes