Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
time.cpp File Reference
#include "mozce_internal.h"
#include "time_conversions.h"

Go to the source code of this file.

Functions

MOZCE_SHUNT_API size_t mozce_strftime (char *, size_t, const char *, const struct tm *)
MOZCE_SHUNT_API struct tmmozce_localtime_r (const time_t *inTimeT, struct tm *outRetval)
MOZCE_SHUNT_API struct tmmozce_localtime (const time_t *inTimeT)
MOZCE_SHUNT_API struct tmmozce_gmtime_r (const time_t *inTimeT, struct tm *outRetval)
MOZCE_SHUNT_API struct tmmozce_gmtime (const time_t *inTimeT)
MOZCE_SHUNT_API time_t mozce_mktime (struct tm *inTM)
MOZCE_SHUNT_API time_t mozce_time (time_t *inStorage)
MOZCE_SHUNT_API char * mozce_ctime (const time_t *timer)

Variables

static const int sDaysOfYear [12]
static struct tm

Function Documentation

MOZCE_SHUNT_API char* mozce_ctime ( const time_t *  timer)

Definition at line 257 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("mozce_ctime called\n");
#endif

    char* retval = NULL;

    if(NULL != timer)
    {
        struct tm tmLocal;
        struct tm* localRes = NULL;

        localRes = mozce_localtime_r(timer, &tmLocal);
        if(NULL != localRes)
        {
            static char ctimeBuf[32];
            size_t strftimeRes = 0;

            // Sat Dec 20 01:05:05 1969\n\0
            strftimeRes = mozce_strftime(ctimeBuf, sizeof(ctimeBuf), "%a %b %d %H %Y\n", &tmLocal);
            if(0 != strftimeRes)
            {
                retval = ctimeBuf;
            }
        }
    }

    return retval;
}

Here is the call graph for this function:

MOZCE_SHUNT_API struct tm* mozce_gmtime ( const time_t *  inTimeT) [read]

Definition at line 181 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("tm* mozce_gmtime called\n");
#endif

    return mozce_gmtime_r(inTimeT, &tmStorage);
}

Here is the call graph for this function:

MOZCE_SHUNT_API struct tm* mozce_gmtime_r ( const time_t *  inTimeT,
struct tm outRetval 
) [read]

Definition at line 130 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("tm* mozce_gmtime_r called\n");
#endif

    struct tm* retval = NULL;

    if(NULL != inTimeT)
    {
        SYSTEMTIME winGMTime;
        
        time_t_2_SYSTEMTIME(winGMTime, *inTimeT);
        
        outRetval->tm_sec = (int)winGMTime.wSecond;
        outRetval->tm_min = (int)winGMTime.wMinute;
        outRetval->tm_hour = (int)winGMTime.wHour;
        outRetval->tm_mday = (int)winGMTime.wDay;
        outRetval->tm_mon = (int)(winGMTime.wMonth - 1);
        outRetval->tm_year = (int)(winGMTime.wYear - 1900);
        outRetval->tm_wday = (int)winGMTime.wDayOfWeek;
        outRetval->tm_isdst = -1;

        outRetval->tm_yday = (int)winGMTime.wDay + sDaysOfYear[outRetval->tm_mon];
        if(0 == (winGMTime.wYear & 3))
        {
            if(2 < winGMTime.wMonth)
            {
                if(0 == winGMTime.wYear % 100)
                {
                    if(0 == winGMTime.wYear % 400)
                    {
                        outRetval->tm_yday++;
                    }
                }
                else
                {
                    outRetval->tm_yday++;
                }
            }
        }

        retval = outRetval;
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MOZCE_SHUNT_API struct tm* mozce_localtime ( const time_t *  inTimeT) [read]

Definition at line 118 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("tm* mozce_localtime called\n");
#endif

    return mozce_localtime_r(inTimeT, &tmStorage);
}

Here is the call graph for this function:

MOZCE_SHUNT_API struct tm* mozce_localtime_r ( const time_t *  inTimeT,
struct tm outRetval 
) [read]

Definition at line 67 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("tm* mozce_localtime_r called\n");
#endif

    struct tm* retval = NULL;

    if(NULL != inTimeT && NULL != outRetval)
    {
        SYSTEMTIME winLocalTime;
        
        time_t_2_LOCALSYSTEMTIME(winLocalTime, *inTimeT);
        
        outRetval->tm_sec = (int)winLocalTime.wSecond;
        outRetval->tm_min = (int)winLocalTime.wMinute;
        outRetval->tm_hour = (int)winLocalTime.wHour;
        outRetval->tm_mday = (int)winLocalTime.wDay;
        outRetval->tm_mon = (int)(winLocalTime.wMonth - 1);
        outRetval->tm_year = (int)(winLocalTime.wYear - 1900);
        outRetval->tm_wday = (int)winLocalTime.wDayOfWeek;
        outRetval->tm_isdst = -1;

        outRetval->tm_yday = (int)winLocalTime.wDay + sDaysOfYear[outRetval->tm_mon];
        if(0 == (winLocalTime.wYear & 3))
        {
            if(2 < winLocalTime.wMonth)
            {
                if(0 == winLocalTime.wYear % 100)
                {
                    if(0 == winLocalTime.wYear % 400)
                    {
                        outRetval->tm_yday++;
                    }
                }
                else
                {
                    outRetval->tm_yday++;
                }
            }
        }

        retval = outRetval;
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MOZCE_SHUNT_API time_t mozce_mktime ( struct tm inTM)

Definition at line 193 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("mozce_mktime called\n");
#endif

    time_t retval = (time_t)-1;

    if(NULL != inTM)
    {
        SYSTEMTIME winTime;
        struct tm* gmTime = NULL;

        memset(&winTime, 0, sizeof(winTime));

        /*
         * Ignore tm_wday and tm_yday.
         * We likely have some problems with dst.
         */
        winTime.wSecond = inTM->tm_sec;
        winTime.wMinute = inTM->tm_min;
        winTime.wHour = inTM->tm_hour;
        winTime.wDay = inTM->tm_mday;
        winTime.wMonth = inTM->tm_mon + 1;
        winTime.wYear = inTM->tm_year + 1900;

        /*
         * First get our time_t.
         */
        SYSTEMTIME_2_time_t(retval, winTime);

        /*
         * Now overwrite the struct passed in with what we believe it should be.
         */
        gmTime = mozce_gmtime_r(&retval, inTM);
    }

    return retval;
}

Here is the call graph for this function:

MOZCE_SHUNT_API size_t mozce_strftime ( char *  ,
size_t  ,
const char *  ,
const struct tm  
)

Definition at line 55 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("mozce_strftime called\n");
#endif

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

MOZCE_SHUNT_API time_t mozce_time ( time_t *  inStorage)

Definition at line 236 of file time.cpp.

{
    MOZCE_PRECHECK

#ifdef DEBUG
    mozce_printf("mozce_time called\n");
#endif

    time_t retval = 0;

    SYSTEMTIME sysTime;
    GetSystemTime(&sysTime);
    SYSTEMTIME_2_time_t(retval, sysTime);

    if(NULL != inStorage)
    {
        *inStorage = retval;
    }
    return retval;
}

Here is the call graph for this function:


Variable Documentation

const int sDaysOfYear[12] [static]
Initial value:
 {
    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
}

Definition at line 50 of file time.cpp.

struct tm [static]

Definition at line 53 of file time.cpp.