コード例 #1
0
ファイル: TimeRange.cpp プロジェクト: DjMomo/calaos_base
string TimeRange::toString()
{
    stringstream str;

    struct tm *ctime = NULL;
    tzset(); //Force reload of timezone data
    time_t t = time(NULL);
    ctime = localtime(&t);

    long start = getStartTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);
    long end = getEndTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);

    if (start_type == HTYPE_NORMAL)
    {
        str << "[Start: normal] (" << time2string_digit(start) << ") ===> ";
    }
    else
    {
        if (start_type == HTYPE_SUNRISE) str << "[Start: sunrise] ";
        if (start_type == HTYPE_SUNSET) str << "[Start: sunset] ";
        if (start_type == HTYPE_NOON) str << "[Start: noon] ";

        str << "(" << time2string_digit(start) << ") ";

        if (shour != "0" || smin != "0" || ssec != "0")
        {
            if (start_offset > 0)
                str << " +offset ";
            else
                str << " -offset ";
            str << "[" << shour << ":" << smin << ":" << ssec << "] ===> ";
        }
        else
            str << " ===> ";
    }

    if (end_type == HTYPE_NORMAL)
    {
        str << "[End: normal] (" << time2string_digit(end) << ")";
    }
    else
    {
        if (end_type == HTYPE_SUNRISE) str << "[End: sunrise] ";
        if (end_type == HTYPE_SUNSET) str << "[End: sunset] ";
        if (end_type == HTYPE_NOON) str << "[End: noon] ";

        str << "(" << time2string_digit(end) << ") ";

        if (ehour != "0" || emin != "0" || esec != "0")
        {
            if (end_offset > 0)
                str << " +offset ";
            else
                str << " -offset ";
            str << "[" << ehour << ":" << emin << ":" << esec << "]";
        }
    }

    return str.str();
}
コード例 #2
0
ファイル: TimeRange.cpp プロジェクト: lovo63/calaos_base
long TimeRange::getEndTimeSec()
{
    struct tm *ctime = NULL;
    time_t t = time(NULL);
    ctime = localtime(&t);

    return getEndTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);
}
コード例 #3
0
ファイル: TimeRange.cpp プロジェクト: DjMomo/calaos_base
long TimeRange::getEndTimeSec()
{
    struct tm *ctime = NULL;
    tzset(); //Force reload of timezone data
    time_t t = time(NULL);
    ctime = localtime(&t);

    return getEndTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);
}
コード例 #4
0
ファイル: TimeRange.cpp プロジェクト: lovo63/calaos_base
bool TimeRange::isSameStartEnd()
{
    struct tm *ctime = NULL;
    time_t t = time(NULL);
    ctime = localtime(&t);

    long start = getStartTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);
    long end = getEndTimeSec(ctime->tm_year + 1900, ctime->tm_mon + 1, ctime->tm_mday);

    return start == end;
}