Ignore:
Timestamp:
Dec 11, 2000, 8:54:20 AM (25 years ago)
Author:
umoeller
Message:

Coupla bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/datetime.c

    r14 r15  
    4141    // as unsigned char
    4242
     43#define INCL_DOSMISC
    4344#include <os2.h>
    4445
     
    7374 *      time in milliseconds.
    7475 *
    75  *      Even though this does handle date information (i.e.
    76  *      will still return an increasing number when the
    77  *      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 second
    82  +            * 60 secs per minute
    83  +                * 60 minutes per hour
    84  +                    * 24 hours per day
    85  +                      = 86'400'000       after 23:59:59:9999
    86  *
    8776 *      A ULONG can hold a max value of 4'294'967'295.
    8877 *      So this overflows after 49.71... days.
    8978 *
    90  *@@changed V0.9.7 (2000-12-05) [umoeller]: now handling date also
     79 *@@V0.9.7 (2000-12-08) [umoeller]: replaced, now using DosQuerySysInfo(QSV_MS_COUNT)
    9180 */
    9281
    9382ULONG dtGetULongTime(VOID)
    9483{
    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;
    10093
    10194    if (G_ulDateScalarFirstCalled == 0)
     
    112105                                              dt.month,
    113106                                              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));
    117109    }
    118110
    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))))); */
    120118}
    121119
Note: See TracChangeset for help on using the changeset viewer.