⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wince_time.cpp

📁 FastDb是高效的内存数据库系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        size_t *count        ){int temp=0;        if (__no_lead_zeros) {                _store_number (num, out, count);                return;        }        if ((size_t)digits < *count)  {                for (digits--; (digits+1); digits--) {                        (*out)[digits] = (char)('0' + num % 10);                        num /= 10;                        temp++;                }                *out += temp;                *count -= temp;        }else        *count = 0;}/****_store_str() - Copy a time string**Purpose:*       Copy the supplied time string into the output string until*       (1) we hit a null in the time string, or (2) the given count*       goes to 0.**       *** For internal use with strftime() only *****Entry:*       char *in = pointer to null terminated time string*       char **out = address of pointer to output string*       size_t *count = address of char count (space in output area)**Exit:*       none*Exceptions:********************************************************************************/static void __cdecl _store_str (        char *in,        char **out,        size_t *count        ){        while ((*count != 0) && (*in != '\0')) {                *(*out)++ = *in++;                (*count)--;        }}/****_store_winword() - Store date/time in WinWord format**Purpose:*       Format the date/time in the supplied WinWord format*       and store it in the supplied buffer.**       *** For internal use with strftime() only *****       The WinWord format is converted token by token to*       strftime conversion specifiers.  _expandtime is then called to*       do the work.  The WinWord format is expected to be a*       character string (not wide-chars).**Entry:*       const char **format = address of pointer to WinWord format*       const struct tm *tmptr = pointer to time/date structure*       char **out = address of pointer to output string*       size_t *count = address of char count (space in output area)*       struct __lc_time_data *lc_time = pointer to locale-specific info**Exit:*       none**Exceptions:********************************************************************************/static void __cdecl _store_winword (        const char *format,        const struct tm *tmptr,        char **out,        size_t *count,        struct __lc_time_data *lc_time        ){        char specifier;        const char *p;        int repeat;        char *ampmstr;        while (*format && *count != 0)        {                specifier = 0;          /* indicate no match */                __no_lead_zeros = 0;    /* default is print leading zeros */                /* count the number of repetitions of this character */                for (repeat=0, p=format; *p++ == *format; repeat++);                /* leave p pointing to the beginning of the next token */                p--;                /* switch on ascii format character and determine specifier */                switch (*format)                {                        case 'M':                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'm'; break;                                        case 3: specifier = 'b'; break;                                        case 4: specifier = 'B'; break;                                } break;                        case 'd':                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'd'; break;                                        case 3: specifier = 'a'; break;                                        case 4: specifier = 'A'; break;                                } break;                        case 'y':                                switch (repeat)                                {                                        case 2: specifier = 'y'; break;                                        case 4: specifier = 'Y'; break;                                } break;                        case 'h':                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'I'; break;                                } break;                        case 'H':                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'H'; break;                                } break;                        case 'm':                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'M'; break;                                } break;                        case 's': /* for compatibility; not strictly WinWord */                                switch (repeat)                                {                                        case 1: __no_lead_zeros = 1; /* fall thru */                                        case 2: specifier = 'S'; break;                                } break;                        case 'A':                        case 'a':                                if (!_stricmp(format, "am/pm"))                                        p = format + 5;                                else if (!_stricmp(format, "a/p"))                                        p = format + 3;                                specifier = 'p';                                break;                        case 't': /* t or tt time marker suffix */                                if ( tmptr->tm_hour <= 11 )                                        ampmstr = lc_time->ampm[0];                                else                                        ampmstr = lc_time->ampm[1];                                while ( (repeat > 0) && (*count > 0) )                                {                                        if ( isleadbyte((int)*ampmstr) &&                                             (*count > 1) )                                        {                                                *(*out)++ = *ampmstr++;                                                (*count)--;                                        }                                        *(*out)++ = *ampmstr++;                                        (*count)--;                                        repeat--;                                }                                format = p;                                continue;                        case '\'': /* literal string */                                if (repeat & 1) /* odd number */                                {                                        format += repeat;                                        while (*format && *count != 0)                                        {                                                if (*format == '\'')                                                {                                                        format++;                                                        break;                                                }                                                if ( isleadbyte((int)*format) &&                                                     (*count > 1) )                                                {                                                        *(*out)++ = *format++;                                                        (*count)--;                                                }                                                *(*out)++ = *format++;                                                (*count)--;                                        }                                }                                else { /* even number */                                        format += repeat;                                }                                continue;                        default: /* non-control char, print it */                                break;                } /* switch */                /* expand specifier, or copy literal if specifier not found */                if (specifier)                {                        _expandtime(specifier, tmptr, out, count, lc_time);                        format = p; /* bump format up to the next token */                } else {                        if (isleadbyte((int)*format))                        {                                *(*out)++ = *format++;                                (*count)--;                        }                        *(*out)++ = *format++;                        (*count)--;                }        } /* while */}/****_store_number() - Convert positive integer to string**Purpose:*       Convert positive integer to a string and store it in the output*       buffer with no null terminator.  Update both the count and*       buffer pointers.**       Differs from _store_num in that the precision is not specified,*       and no leading zeros are added.**       *** For internal use with strftime() only *****       Created from xtoi.c**Entry:*       int num = pointer to integer value*       char **out = address of pointer to output string*       size_t *count = address of char count (space in output area)**Exit:*       none**Exceptions:*       The buffer is filled until it is out of space.  There is no*       way to tell beforehand (as in _store_num) if the buffer will*       run out of space.********************************************************************************/static void __cdecl _store_number (        int num,        char **out,        size_t *count        ){        char *p;                /* pointer to traverse string */        char *firstdig;         /* pointer to first digit */        char temp;              /* temp char */        p = *out;        /* put the digits in the buffer in reverse order */        if (*count > 1)        {                do {                        *p++ = (char) (num % 10 + '0');                        (*count)--;                } while ((num/=10) > 0 && *count > 1);        }        firstdig = *out;                /* firstdig points to first digit */        *out = p;                       /* return pointer to next space */        p--;                            /* p points to last digit */        /* reverse the buffer */        do {                temp = *p;                *p-- = *firstdig;                *firstdig++ = temp;     /* swap *p and *firstdig */        } while (firstdig < p);         /* repeat until halfway */}/****void tzset() - sets timezone information and calc if in daylight time**Purpose:*       Sets the timezone information from the TZ environment variable*       and then sets _timezone, _daylight, and _tzname. If we're in daylight*       time is automatically calculated.**Entry:*       None, reads TZ environment variable.**Exit:*       sets _daylight, _timezone, and _tzname global vars, no return value**Exceptions:********************************************************************************/void __cdecl __tzset(void){        int defused;        int negdiff = 0;        /*         * Clear the flag indicated whether GetTimeZoneInformation was used.         */        tzapiused = 0;        /*         * Set year fields of dststart and dstend structures to -1 to ensure         * they are recomputed as after this         */        dststart.yr = dstend.yr = -1;        /*         * Fetch the value of the TZ environment variable.         */        if ( 1 /*(TZ = _getenv_lk("TZ")) == NULL */) {            /*             * There is no TZ environment variable, try to use the time zone             * information from the system.             */            if ( GetTimeZoneInformation( &tzinfo ) != 0xFFFFFFFF ) {                /*                 * Note that the API was used.                 */                tzapiused = 1;                /*                 * Derive _timezone value from Bias and StandardBias fields.                 */                _timezone = tzinfo.Bias * 60L;                if ( tzinfo.StandardDate.wMonth != 0 )                    _timezone += (tzinfo.StandardBias * 60L);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -