[Webkit-unassigned] [Bug 9651] MSVCRT time functions are too strict

bugzilla-daemon at opendarwin.org bugzilla-daemon at opendarwin.org
Tue Jul 11 20:02:26 PDT 2006


http://bugzilla.opendarwin.org/show_bug.cgi?id=9651


darin at apple.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #9383|review?                     |review-
               Flag|                            |




------- Comment #8 from darin at apple.com  2006-07-11 20:02 PDT -------
(From update of attachment 9383)
+    int dfy = dayFromYear((int)year);

no need for type cast

+    if (day < dfy) {
+        // The first day of year is beyond day, so we have right year + 1
+        year -= 1;
     }

no need for braces

-  static double time_tMin = (time_tIsSigned ? - (double)(1ULL << (8 *
sizeof(time_t) - 1)) : 0);
+  if (secs < 0 || secs > time_tMax) {

If this is removed, so that mean that time_tIsSigned is not needed any more?

-  char timebuffer[bufsize];
+  wchar_t timebuffer[bufsize];

What's the rationale for this change?

+      size_t len = WTF::wcsftime(timebuffer, bufsize, L"%c", &t);
+      return jsString(UString((UChar*)timebuffer, len));

This assumes that wchar_t is the same as UChar, but that's not going to be true
on platforms other than Windows.

+        struct tm t3;

Should be just "tm", not "struct tm", right?

+/*
+*/

What is that empty comment about?

+inline bool getTimeZoneInfo() {
+inline SYSTEMTIME tmToSystemTime(const struct tm& tm) {

We put braces on the next line when defining functions.

+    //FIXME: Cache the result per thread

We put spaces after // comments.

+inline bool operator >=(const struct tm& a, const struct tm& b)
+{
+    bool res = false;
+    if (a.tm_year == b.tm_year) {
+        if (a.tm_mon > b.tm_mon) {
+            res = true;
+        } else if (a.tm_mon == b.tm_mon) {
+            if (a.tm_mday > b.tm_mday) {
+                res = true;
+            } else if (a.tm_mday == b.tm_mday) {
+                if (a.tm_hour > b.tm_hour) {
+                    res = true;
+                } else if (a.tm_hour == b.tm_hour) {
+                    if (a.tm_min >= b.tm_min) {
+                        res = true;
+                    }
+                }
+            }
+        }
+    }
+    return res;

Would read a lot better if it had a few more return statements in it.

+static inline tm* gmtime(const time_t* timer) { return ::gmtime(timer); }
+static inline tm* localtime(const time_t* timer) { return ::localtime(timer);
}
+static inline time_t mktime(tm* time) { return ::mktime(time); }
+static inline size_t wcsftime(wchar_t* dest, size_t maxsize, const wchar_t*
format, const tm* timeptr) { return ::wcsftime(dest, maxsize, format, timeptr);
}

These should not have "static" in front of them -- just inline.

+#ifndef _DATEEXTRAS_H_

Should not use a leading underscore -- that's reserved for the compiler and
library.

+#if HAVE(SYS_TIME_H)
+#if PLATFORM(WIN)

Need to include "Platform.h" first if a header file is going to use these
macros.


-- 
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list