Changeset 5987 in vbox for trunk/src/VBox/Main/xml/cfgldr.cpp
- Timestamp:
- Dec 6, 2007 2:09:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/cfgldr.cpp
r5969 r5987 59 59 #include <iprt/time.h> 60 60 #include <iprt/alloc.h> 61 62 /// @todo (dmik) until RTTimeNormalize and friends are done63 #include <time.h>64 61 65 62 #include <xercesc/util/PlatformUtils.hpp> … … 2830 2827 rc = VERR_PARSE_ERROR; 2831 2828 2832 #if 02833 2829 RTTIME time = { yyyy, (uint8_t) mm, 0, 0, (uint8_t) dd, 2834 (uint8_t) hh, (uint8_t) m m, (uint8_t) ss, 0,2830 (uint8_t) hh, (uint8_t) mi, (uint8_t) ss, 0, 2835 2831 RTTIME_FLAGS_TYPE_UTC }; 2836 2832 if (RTTimeNormalize (&time)) … … 2843 2839 } 2844 2840 } 2845 #else2846 /// @todo (dmik) until RTTimeNormalize and friends are done2847 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 dirty2864 * trick to get the right time value. Note that the trick doesn't2865 * work when UTC + timezone_offset goes before midnight, 1.1.19702866 * (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 #endif2877 2841 } 2878 2842 else … … 2894 2858 } 2895 2859 2896 #if 02897 2860 RTTIMESPEC timeSpec; 2898 RTTimeSpecSetMilli (&timeSpec, i64Value);2861 RTTimeSpecSetMilli (&timeSpec, i64Value); 2899 2862 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)) 2906 2864 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' */ 2915 2869 char aszBuf [256]; 2916 2870 RTStrPrintf(aszBuf, sizeof(aszBuf), 2917 2871 "%04ld-%02hd-%02hdT%02hd:%02hd:%02hdZ", 2918 #if 02919 2872 time.i32Year, (uint16_t) time.u8Month, (uint16_t) time.u8MonthDay, 2920 2873 (uint16_t) time.u8Hour, (uint16_t) time.u8Minute, (uint16_t) time.u8Second); 2921 #else2922 /// @todo (dmik) until RTTimeNormalize and friends are done2923 time.tm_year, time.tm_mon, time.tm_mday,2924 time.tm_hour, time.tm_min, time.tm_sec);2925 #endif2926 2874 2927 2875 return hnode->SetString (pszName, aszBuf, strlen (aszBuf), false);
Note:
See TracChangeset
for help on using the changeset viewer.