OSSP CVS Repository

ossp - Difference in ossp-pkg/tai/tai_lib.c versions 1.6 and 1.7
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/tai/tai_lib.c 1.6 -> 1.7

--- tai_lib.c    2002/08/14 13:34:01     1.6
+++ tai_lib.c    2002/08/14 14:28:27     1.7
@@ -56,12 +56,40 @@
 {
     if (tai == NULL)
         return TAI_ERR_ARG;
-    if (tai->tai_zone != NULL)
-        free(tai->tai_zone);
     free(tai);
     return TAI_OK;
 }
 
+#if 0
+static time_t tai_utcoffset(void)
+{
+    time_t tL, tU;
+    struct tm *tmL, *tmU;
+    time_t offset;
+
+    /* determine local time (UTC based) */
+    tL = time(NULL); /* theoretically this could be a constant value, too */
+
+    /* unpack local time (local time based) */
+    tmL = localtime(&tL);
+
+    /* unpack local time (UTC based) */
+    tmU = gmtime(&tL);
+
+    /* pack UTC-based local time back into local time */
+    tU  = mktime(tmU);
+
+    /* local time adjustment for Daylight Saving Time (DST) */
+    if (tmL->tm_isdst)
+        tL += (60*60);
+
+    /* finally calculate the UTC offset */
+    offset = (tL - tU);
+
+    return offset;
+}
+#endif
+
 tai_rc_t tai_import(tai_t *tai, tai_type_t type, ...)
 {
     va_list ap;
@@ -91,11 +119,11 @@
         tai->tai_wday   = stm->tm_wday;
         tai->tai_yday   = stm->tm_yday;
         tai->tai_isdst  = stm->tm_isdst;
-        tai->tai_gmtoff = stm->tm_gmtoff;
-        if (stm->tm_zone == NULL)
-            tai->tai_zone = strdup("");
-        else
-            tai->tai_zone = strdup(stm->tm_zone);
+#ifdef HAVE_TM_GMTOFF
+        tai->tai_gmtoff = stm->tm_gmtoff; /* implicitly 0 */
+#else
+        tai->tai_gmtoff = 0;              /* explicitly 0 */
+#endif
     }
     else if (type == TAI_TYPE_STRUCTTM) {
         /* import from struct tm */
@@ -121,11 +149,11 @@
         tai->tai_wday   = stm->tm_wday;
         tai->tai_yday   = stm->tm_yday;
         tai->tai_isdst  = stm->tm_isdst;
+#ifdef HAVE_TM_GMTOFF
         tai->tai_gmtoff = stm->tm_gmtoff;
-        if (stm->tm_zone == NULL)
-            tai->tai_zone = strdup("");
-        else
-            tai->tai_zone = strdup(stm->tm_zone);
+#else
+        tai->tai_gmtoff = 0;
+#endif
     }
     else if (type == TAI_TYPE_UNIX) {
         /* import from time(3) FIXME */
@@ -165,8 +193,9 @@
         stm->tm_wday   = tai->tai_wday;
         stm->tm_yday   = tai->tai_yday;
         stm->tm_isdst  = tai->tai_isdst;
+#ifdef HAVE_TM_GMTOFF
         stm->tm_gmtoff = tai->tai_gmtoff;
-        stm->tm_zone   = tai->tai_zone;
+#endif
 #ifdef HAVE_TIMEGM
         /* non-standard timegm(3) makes our life easy */
         *pt = timegm(stm);
@@ -191,8 +220,9 @@
         stm->tm_wday   = tai->tai_wday;
         stm->tm_yday   = tai->tai_yday;
         stm->tm_isdst  = tai->tai_isdst;
+#ifdef HAVE_TM_GMTOFF
         stm->tm_gmtoff = tai->tai_gmtoff;
-        stm->tm_zone   = strdup(tai->tai_zone);
+#endif
     }
     else
         return TAI_ERR_IMP; /* FIXME */

CVSTrac 2.0.1