Changeset 15 for trunk/src/helpers/datetime.c
- Timestamp:
- Dec 11, 2000, 8:54:20 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/datetime.c
r14 r15 41 41 // as unsigned char 42 42 43 #define INCL_DOSMISC 43 44 #include <os2.h> 44 45 … … 73 74 * time in milliseconds. 74 75 * 75 * Even though this does handle date information (i.e.76 * will still return an increasing number when the77 * clock switches from 23:59:59:9999 to 0:00:00:0000),78 * this will not work forver after the first call.79 * Here's the calculation:80 *81 + 1000 ms per second82 + * 60 secs per minute83 + * 60 minutes per hour84 + * 24 hours per day85 + = 86'400'000 after 23:59:59:999986 *87 76 * A ULONG can hold a max value of 4'294'967'295. 88 77 * So this overflows after 49.71... days. 89 78 * 90 *@@ changed V0.9.7 (2000-12-05) [umoeller]: now handling date also79 *@@V0.9.7 (2000-12-08) [umoeller]: replaced, now using DosQuerySysInfo(QSV_MS_COUNT) 91 80 */ 92 81 93 82 ULONG dtGetULongTime(VOID) 94 83 { 95 DATETIME dt; 96 ULONG ulTime, 97 ulDateScalarPassed = 1; 98 DosGetDateTime(&dt); 99 ulTime = (10*(dt.hundredths + 100*(dt.seconds + 60*(dt.minutes + 60*(dt.hours))))); 84 ULONG ulTimeNow; 85 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, 86 &ulTimeNow, 87 sizeof(ulTimeNow)); 88 return (ulTimeNow); 89 90 /* DATETIME dt; 91 ULONG ulHours, 92 ulDaysPassed = 0; 100 93 101 94 if (G_ulDateScalarFirstCalled == 0) … … 112 105 dt.month, 113 106 dt.day); 114 // calculate days passed since first call; 115 // this should be 1 if the date hasn't changed 116 ulDateScalarPassed = (G_ulDateScalarFirstCalled - ulDateScalarNow) + 1; 107 ulDaysPassed = (ulDateScalarNow - G_ulDateScalarFirstCalled); 108 _Pmpf((__FUNCTION__ ": days passed = %d", ulDaysPassed)); 117 109 } 118 110 119 return (ulTime * ulDateScalarPassed); 111 DosGetDateTime(&dt); 112 ulHours = dt.hours; // this is UCHAR in DATETIME 113 // get the hours; for every day passed, add 24 hours... 114 ulHours += (24 * ulDaysPassed); 115 // 0 if we're still on the first date 116 117 return (10*(dt.hundredths + 100*(dt.seconds + 60*(dt.minutes + 60*(ulHours))))); */ 120 118 } 121 119
Note:
See TracChangeset
for help on using the changeset viewer.