Esempio n. 1
0
char    *_FARFUNC asctime(const struct tm *tmPtr)
{
#if !defined( _RTLDLL )
    static char a[26];
#endif
    int end;
    _QRTLDataBlock;

    end = atime( _QRTLInstanceData(a), tmPtr );
    _QRTLInstanceData(a)[end++] = '\n';        //  add terminating newline
    _QRTLInstanceData(a)[end] = '\0';

    return(_QRTLInstanceData(a));
}
static char * near pascal _maperror(int errnum, const char *s)
{
    char    *cp;
    _QRTLDataBlock;

    if (errnum < sys_nerr && errnum >= 0)
        cp = sys_errlist[errnum];
    else
        cp = "Unknown error";
    if (s && *s)
        sprintf(_QRTLInstanceData(strbuf), "%s: %s\n", s, cp);
    else
        sprintf(_QRTLInstanceData(strbuf), "%s\n", cp);
    return _QRTLInstanceData(strbuf);
}
Esempio n. 3
0
/*---------------------------------------------------------------------*

Name            comtime

Usage           static struct tm *comtime(unsigned long time, int dst);

Prototype in    local to this module

Description     fills the time structure tm by translating the long
                time.

Return value    the broken down time structure. This structure is
                a static which is overwritten with each call.

*---------------------------------------------------------------------*/
static  struct  tm *comtime(time_t time, int dst)
{
    int      hpery;
    unsigned i;
    unsigned cumdays;
    _QRTLDataBlock;

    if (time < 0)
        time = 0;

    _QRTLInstanceData(tmX).tm_sec = (int)(time % 60);
    time /= 60;                             /* Time in minutes */
    _QRTLInstanceData(tmX).tm_min = (int)(time % 60);
    time /= 60;                             /* Time in hours */
    i = (unsigned)(time / (1461L * 24L));   /* Number of 4 year blocks */
    _QRTLInstanceData(tmX).tm_year = (i << 2);
    _QRTLInstanceData(tmX).tm_year+= 70;
    cumdays = 1461 * i;
    time %= 1461L * 24L;        /* Hours since end of last 4 year block */

    for (;;)
        {
        hpery = 365 * 24;
        if ((_QRTLInstanceData(tmX).tm_year & 3) == 0)
            hpery += 24;
        if (time < hpery)
            break;
        cumdays += hpery / 24;
        _QRTLInstanceData(tmX).tm_year++;
        time -= hpery;
        }   /* at end, time is number of hours into current year */

    if  (dst && daylight &&
             __isDST( (int)(time % 24), (int)(time / 24), 0, _QRTLInstanceData(tmX).tm_year-70))
        {
        time++;
        _QRTLInstanceData(tmX).tm_isdst = 1;
        }
    else
        _QRTLInstanceData(tmX).tm_isdst = 0;

    _QRTLInstanceData(tmX).tm_hour = (int)(time % 24);
    time /= 24;             /* Time in days */
    _QRTLInstanceData(tmX).tm_yday = (int)time;
    cumdays += (int)time + 4;
    _QRTLInstanceData(tmX).tm_wday = cumdays % 7;
    time++;

    if ((_QRTLInstanceData(tmX).tm_year & 3) == 0)
        {
        if (time > 60)
            time--;
        else
            if (time == 60)
                {
                _QRTLInstanceData(tmX).tm_mon = 1;
                _QRTLInstanceData(tmX).tm_mday = 29;
                return(&_QRTLInstanceData(tmX));
                }
        }

    for (_QRTLInstanceData(tmX).tm_mon = 0; Days[_QRTLInstanceData(tmX).tm_mon] < time; _QRTLInstanceData(tmX).tm_mon++)
        time -= Days[_QRTLInstanceData(tmX).tm_mon];

    _QRTLInstanceData(tmX).tm_mday = (int)(time);
    return(&_QRTLInstanceData(tmX));
}