VirtualBox

Ignore:
Timestamp:
Dec 6, 2007 2:09:40 PM (17 years ago)
Author:
vboxsync
Message:

Main: Use RTTime* API for time processing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/cfgldr.cpp

    r5969 r5987  
    5959#include <iprt/time.h>
    6060#include <iprt/alloc.h>
    61 
    62 /// @todo (dmik) until RTTimeNormalize and friends are done
    63 #include <time.h>
    6461
    6562#include <xercesc/util/PlatformUtils.hpp>
     
    28302827            rc = VERR_PARSE_ERROR;
    28312828
    2832 #if 0
    28332829            RTTIME time = { yyyy, (uint8_t) mm, 0, 0, (uint8_t) dd,
    2834                             (uint8_t) hh, (uint8_t) mm, (uint8_t) ss, 0,
     2830                            (uint8_t) hh, (uint8_t) mi, (uint8_t) ss, 0,
    28352831                            RTTIME_FLAGS_TYPE_UTC };
    28362832            if (RTTimeNormalize (&time))
     
    28432839                }
    28442840            }
    2845 #else
    2846             /// @todo (dmik) until RTTimeNormalize and friends are done
    2847             int isdst = 0;
    2848             {
    2849                 time_t dummyt = time(NULL);
    2850                 isdst = localtime(&dummyt)->tm_isdst;
    2851             }
    2852             tm time;
    2853             time.tm_hour = hh;   /* hour (0 - 23) */
    2854             time.tm_isdst = isdst;  /* daylight saving time enabled/disabled */
    2855             time.tm_mday = dd;   /* day of month (1 - 31) */
    2856             time.tm_min = mi;    /* minutes (0 - 59) */
    2857             time.tm_mon = mm - 1;    /* month (0 - 11 : 0 = January) */
    2858             time.tm_sec = ss;    /* seconds (0 - 59) */
    2859             time.tm_wday = 0;   /* Day of week (0 - 6 : 0 = Sunday) */
    2860             time.tm_yday = 0;   /* Day of year (0 - 365) */
    2861             time.tm_year = yyyy - 1900;   /* Year less 1900 */
    2862             time_t t = mktime(&time);
    2863             /* mktime expects local time, but we supply it UTC, do a dirty
    2864              * trick to get the right time value. Note that the trick doesn't
    2865              * work when UTC + timezone_offset goes before midnight, 1.1.1970
    2866              * (gmtime() will return NULL on failure) */
    2867             tm *dummytm = gmtime(&t);
    2868             if (dummytm)
    2869             {
    2870                 dummytm->tm_isdst = isdst;
    2871                 time_t delta = t - mktime(dummytm);
    2872                 *pi64Value = t + delta;
    2873                 *pi64Value *= 1000;
    2874                 rc = VINF_SUCCESS;
    2875             }
    2876 #endif
    28772841        }
    28782842        else
     
    28942858    }
    28952859
    2896 #if 0
    28972860    RTTIMESPEC timeSpec;
    2898     RTTimeSpecSetMilli(&timeSpec, i64Value);
     2861    RTTimeSpecSetMilli (&timeSpec, i64Value);
    28992862    RTTIME time;
    2900     RTTimeExplode(&time, &timeSpec);
    2901 #else
    2902     /// @todo (dmik) until RTTimeNormalize and friends are done
    2903     time_t t = (time_t)(i64Value / 1000);
    2904     tm *ptm = gmtime(&t);
    2905     if (!ptm)
     2863    if (!RTTimeExplode (&time, &timeSpec))
    29062864        return VERR_PARSE_ERROR;
    2907     tm time = *ptm;
    2908     time.tm_year += 1900;
    2909     time.tm_mon += 1;
    2910 #endif
    2911 
    2912     // Store xsd:dateTime. The format is:
    2913     // '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
    2914     // where zzzzzz is: (('+' | '-') hh ':' mm) | 'Z'
     2865
     2866    /* Store xsd:dateTime. The format is:
     2867     * '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
     2868     * where zzzzzz is: (('+' | '-') hh ':' mm) | 'Z' */
    29152869    char aszBuf [256];
    29162870    RTStrPrintf(aszBuf, sizeof(aszBuf),
    29172871                "%04ld-%02hd-%02hdT%02hd:%02hd:%02hdZ",
    2918 #if 0
    29192872                time.i32Year, (uint16_t) time.u8Month, (uint16_t) time.u8MonthDay,
    29202873                (uint16_t) time.u8Hour, (uint16_t) time.u8Minute, (uint16_t) time.u8Second);
    2921 #else
    2922                 /// @todo (dmik) until RTTimeNormalize and friends are done
    2923                 time.tm_year, time.tm_mon, time.tm_mday,
    2924                 time.tm_hour, time.tm_min, time.tm_sec);
    2925 #endif
    29262874
    29272875    return hnode->SetString (pszName, aszBuf, strlen (aszBuf), false);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette