亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? basictime.cpp

?? funambol windows mobile plugin source code, the source code is taken from the funambol site
?? CPP
字號:
/*
 * Copyright (C) 2003-2007 Funambol, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 * 02111-1307  USA
 */

#include <base/test.h>

#include "base/util/BasicTime.h"

BasicTime::BasicTime() {
    year = 1970;
    month = 1;
    day = 1;
    weekday = 0;
    hour = 0;
    min = 0;
    sec = 0;
    tzHour = 0;
    tzMin = 0;
}

int BasicTime::set(int yy, int mon, int dd, int wd,
                   int hh, int mm, int ss, int tzh, int tzm)
{
    //  TODO
    return 0;
}

/**
 * Parse the date in RF 822 format
 *
 * Some examples:
 * Date: Fri, 01 Aug 2003 14:04:55 +0800
 * Date: Wed, 30 Jul 2003 13:24:21 -0700
 * Date: 20 Jun 2003 15:42:12 -0500
 *
 * RFC822 date time
 *
 *   date-time   =  [ day "," ] date time        ; dd mm yy
 *                                              ;  hh:mm:ss zzz
 *
 *   day         =  "Mon"  / "Tue" /  "Wed"  / "Thu"
 *               /  "Fri"  / "Sat" /  "Sun"
 *
 *   date        =  1*2DIGIT month 2DIGIT        ; day month year
 *                                               ;  e.g. 20 Jun 82
 *
 *   month       =  "Jan"  /  "Feb" /  "Mar"  /  "Apr"
 *               /  "May"  /  "Jun" /  "Jul"  /  "Aug"
 *               /  "Sep"  /  "Oct" /  "Nov"  /  "Dec"
 *
 *   time        =  hour zone                    ; ANSI and Military
 *
 *   hour        =  2DIGIT ":" 2DIGIT [":" 2DIGIT]
 *                                               ; 00:00:00 - 23:59:59
 *
 *   zone        =  "UT"  / "GMT"                ; Universal Time
 *                                               ; North American : UT
 *               /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
 *               /  "CST" / "CDT"                ;  Central:  - 6/ - 5
 *               /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
 *               /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
 *               /  1ALPHA                       ; Military: Z = UT;
 *                                               ;  A:-1; (J not used)
 *                                               ;  M:-12; N:+1; Y:+12
 *               / ( ("+" / "-") 4DIGIT )        ; Local differential
 *                                               ;  hours+min. (HHMM)
**/
int BasicTime::parseRfc822(const char *date)
{

    int ret = 0;
    if (!isADate(date)) {
        return -1;
    }

	const char *days[] = {
        "Sun", "Mon", "Tue", "Wed",
        "Thu", "Fri", "Sat"
    };
	const char *months[] = {
        "Jan", "Feb", "Mar", "Apr",
        "May", "Jun", "Jul", "Aug",
        "Sep", "Oct", "Nov", "Dec"
    };
	char dayOfWeek[6] = "---,";
	char mon[4] = "---";
	char time[10] = "00:00:00";
	char timeZone[20] = "GMT";

    // Wed Feb 01 14:40:45 Europe/Amsterdam 2006
	// do we have day of week?
    const char *pdate = strstr( date, "," );
	if ( pdate == 0 ) {
		ret=sscanf(date, "%d %s %d %s %s",
            &day, mon, &year, time, timeZone);
    }
	else {
		ret=sscanf(date, "%s %d %s %d %s %s",
            dayOfWeek, &day, mon, &year, time, timeZone);
        if (ret >= 1 && ret < 6) {
            // it can be an error in the format: Mon,12 Feb 2007 09:00:01 +0100
            // the comma is attached to the day
            if (*(pdate + 1) != ' ') {
                ret = sscanf(pdate + 1, "%d %s %d %s %s",
                    &day, mon, &year, time, timeZone);

            }
        }
    }
    // Trap parsing error
    if(ret == EOF || ret == 0){
        return -1;
    }
    if (year > 3000 || day < 0 || day > 31){
        *this = BasicTime();
        return -1;
    }

    // Get month
    int i;
	for (i = 0; i < 12; i++) {
		if ( strcmp(months[i], mon) == 0 ) {
            month = i+1;
			break;
        }
	}
    // Trap parsing error
    if (i==13)
        return -1;

	// Year ---------------------------------
	if (year < 100) year += 1900;

	// hh:mm:ss -------------------------
	// do we have sec?
	if (strlen(time) > 6 && time[5] == ':')
		sscanf(time, "%d:%d:%d", &hour, &min, &sec);
	else
		sscanf(time, "%d:%d", &hour, &min);

	// Timezone ---------------------------------
    if ( strcmp(timeZone, "GMT") != 0 && strcmp(timeZone, "UT") != 0) {
		// is this explicit time?
		if ( timeZone[0] == '+' || timeZone[0]== '-' ) {
			char wcH[4] = "+00";
			char wcM[4] = "00";

			// get hour
			if ( strlen(timeZone) > 3) {
				wcH[0] = timeZone[0];
				wcH[1] = timeZone[1];
				wcH[2] = timeZone[2];
				wcH[3] = '\0';
			}
			// get min
			if ( strlen(timeZone) >= 5)	{
				wcM[0] = timeZone[3];
				wcM[1] = timeZone[4];
				wcM[2] = '\0';
			}
			tzHour = atoi(wcH);
			tzMin = atoi(wcM);
		}
		// otherwise it could be one string with the time
        else if ( strcmp(timeZone, "EDT") == 0) {
			tzHour = -4;
        }
		else if ( strcmp(timeZone, "EST") == 0
            ||  strcmp(timeZone, "CDT") == 0) {
			tzHour = -5;
        }
		else if ( strcmp(timeZone, "CST") == 0
            ||  strcmp(timeZone, "MDT") == 0) {
			tzHour = -6;
        }
		else if ( strcmp(timeZone, "MST") == 0
            ||  strcmp(timeZone, "PDT") == 0 ){
			tzHour = -7;
        }
        else if ( strcmp(timeZone, "PST") == 0) {
			tzHour = -8;
        }
	}

	// clean up
	return 0;
}

/*
* The function return if the argument passed is a date in a format
* we are searching. To decide it the date must contain the month, a space
* and the millennium
*
* Mar 2007, Jun 2007. We search Mar 2, Jun 2.
* If no one of them is found try with the millenium 1XXX
*
*/
bool BasicTime::isADate(const char* date) {
    const char *months2000[] = {
        "Jan 2", "Feb 2", "Mar 2", "Apr 2",
        "May 2", "Jun 2", "Jul 2", "Aug 2",
        "Sep 2", "Oct 2", "Nov 2", "Dec 2"
    };

    const char *months1000[] = {
        "Jan 1", "Feb 1", "Mar 1", "Apr 1",
        "May 1", "Jun 1", "Jul 1", "Aug 1",
        "Sep 1", "Oct 1", "Nov 1", "Dec 1"
    };
    for (int i = 0; i < 12; i++) {
        if (strstr(date, months2000[i]) != NULL) {
            return true;
        }
    }
    for (int i = 0; i < 12; i++) {
        if (strstr(date, months1000[i]) != NULL) {
            return true;
        }
    }
    return false;

}



// Date: Fri, 01 Aug 2003 14:04:55 +0800
char *BasicTime::formatRfc822() const {
	const char *days[] = {
        "Sun", "Mon", "Tue", "Wed",
        "Thu", "Fri", "Sat", "Sun"
    };
	const char *months[] = {
        "Jan", "Feb", "Mar", "Apr",
        "May", "Jun", "Jul", "Aug",
        "Sep", "Oct", "Nov", "Dec"
    };
    char *ret = new char[60]; // FIXME: avoid sprintf and static size

    sprintf(ret, "%s, %d %s %d %02d:%02d:%02d %+03d%02d",
                  days[weekday], day, months[month-1], year, hour, min, sec,
                  tzHour, tzMin);

    return ret;
}

ArrayElement *BasicTime::clone() {
    return new BasicTime(*this);
};

BasicTime& BasicTime::operator=(const BasicTime& o) {
    year = o.year;
    month = o.month;
    day = o.day;
    weekday = o.weekday;
    hour = o.hour;
    min = o.min;
    sec = o.sec;
    tzHour = o.tzHour;
    tzMin = o.tzMin;

    return *this;
}

bool BasicTime::operator==(const BasicTime& o) const {
    return (
        year == o.year &&
        month == o.month &&
        day == o.day &&
        weekday == o.weekday &&
        hour == o.hour &&
        min == o.min &&
        sec == o.sec &&
        tzHour == o.tzHour &&
        tzMin == o.tzMin
    );
}

#ifdef ENABLE_UNIT_TESTS


class BasicTimeTest : public CppUnit::TestFixture {
    CPPUNIT_TEST_SUITE(BasicTimeTest);
    CPPUNIT_TEST(testEqual);
    CPPUNIT_TEST(testConversion);
    CPPUNIT_TEST_SUITE_END();

public:
    void setUp() {
        // millenium.set(2000, 01, 01, 6,
        //              00, 00, 00,
        //              00, 00);
        millenium.setYear(2000);
        buffer = NULL;
    }
    void tearDown() {
        if (buffer) {
            delete [] buffer;
        }
    }

protected:
    void testEqual() {
        BasicTime empty;
        CPPUNIT_ASSERT(empty != millenium);

        BasicTime copy(millenium);
        CPPUNIT_ASSERT(millenium == copy);
        copy = millenium;
        CPPUNIT_ASSERT(millenium == copy);
    }

    void testConversion() {
        buffer = millenium.formatRfc822();

        BasicTime copy;
        CPPUNIT_ASSERT_EQUAL(0, copy.parseRfc822(buffer));
        CPPUNIT_ASSERT(millenium == copy);
        delete [] buffer; buffer = NULL;

        CPPUNIT_ASSERT_EQUAL(-1, copy.parseRfc822("this is garbage"));

        static const char convertStr[] = "Mon, 6 Nov 2006 20:30:15 +0100";
        BasicTime convert;
        CPPUNIT_ASSERT_EQUAL(0, convert.parseRfc822(convertStr));
        buffer = convert.formatRfc822();
        CPPUNIT_ASSERT(!strcmp(buffer, convertStr));
        delete [] buffer; buffer = NULL;
    }

private:
    BasicTime millenium;
    char *buffer;
};

FUNAMBOL_TEST_SUITE_REGISTRATION(BasicTimeTest);

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品久久久久久久久久久久包黑料| 粉嫩高潮美女一区二区三区| 夜夜揉揉日日人人青青一国产精品| 国产精品久久久久久久久久久免费看 | 国产精品久久久一区麻豆最新章节| 精品影院一区二区久久久| 国产最新精品精品你懂的| av中文字幕在线不卡| 91精品国产综合久久久久久久久久| 欧美一区二区三区性视频| 久久精品视频在线看| 亚洲综合色婷婷| 国产精品77777| 欧美性猛交xxxx乱大交退制版 | 欧美男女性生活在线直播观看| 亚洲精品一区二区三区福利 | 欧美性生活影院| 亚洲国产一区二区三区青草影视| 蜜乳av一区二区| www.欧美色图| 亚洲综合在线视频| 8x福利精品第一导航| 久久91精品国产91久久小草| 国产日韩欧美在线一区| 亚洲午夜一区二区| 在线不卡一区二区| 亚洲黄色免费电影| 国产成人啪午夜精品网站男同| 这里只有精品电影| 极品瑜伽女神91| 国产精品久久福利| 欧美色图第一页| 亚洲男帅同性gay1069| 国产aⅴ综合色| 亚洲激情自拍视频| 日韩欧美另类在线| 久久福利资源站| 欧美一卡2卡三卡4卡5免费| 国产一区二区精品久久99| 欧美一区二区精品在线| 国产成都精品91一区二区三| 亚洲与欧洲av电影| 久久久久久久久久美女| 国产在线国偷精品免费看| 国产精品久久久久7777按摩| 欧美一卡二卡在线观看| 91在线你懂得| 一区二区三区日本| 久久久午夜精品理论片中文字幕| 97aⅴ精品视频一二三区| 久久国产精品第一页| 伊人一区二区三区| 欧美激情一区在线观看| 成人精品鲁一区一区二区| 中文字幕成人av| 日韩欧美资源站| 极品美女销魂一区二区三区 | 制服丝袜日韩国产| 色狠狠一区二区| 亚洲特级片在线| 色综合一区二区| 亚洲精品欧美二区三区中文字幕| 精品奇米国产一区二区三区| 欧美性大战久久久| 91欧美一区二区| 亚洲高清视频中文字幕| 国产清纯美女被跳蛋高潮一区二区久久w | 在线免费观看不卡av| 亚洲一区二区3| 国产精品久久久一本精品| 久久久久久久久久久99999| 在线电影欧美成精品| 欧美日韩视频一区二区| 色天天综合久久久久综合片| 肉肉av福利一精品导航| 日韩你懂的电影在线观看| 欧美性生活久久| 一本到不卡免费一区二区| 成人高清在线视频| 国产xxx精品视频大全| 国产乱码一区二区三区| 激情久久久久久久久久久久久久久久| 日韩黄色小视频| 日本亚洲视频在线| 国产精品美日韩| 欧美军同video69gay| 欧美午夜免费电影| 欧美性videosxxxxx| 欧美午夜电影在线播放| 欧美日韩国产欧美日美国产精品| 欧美最猛黑人xxxxx猛交| 欧美日韩一区在线观看| 欧美人妖巨大在线| 欧美日本乱大交xxxxx| 欧美一区二区视频在线观看| 91精品国产91久久综合桃花| 久久综合色综合88| 国产69精品久久久久777| 成人的网站免费观看| 麻豆成人av在线| 免费欧美日韩国产三级电影| 国产精品国产精品国产专区不蜜| 国产日韩欧美精品一区| 中文字幕亚洲区| 精品国产伦理网| 26uuu精品一区二区三区四区在线| 久久久亚洲高清| 亚洲另类在线制服丝袜| 五月婷婷激情综合| 国产精品传媒视频| 亚洲欧美二区三区| 午夜亚洲福利老司机| 久久99国产精品免费网站| 成人国产免费视频| 欧美日韩国产系列| 国产亚洲精品aa午夜观看| 亚洲精品伦理在线| 日本不卡一区二区三区高清视频| 麻豆久久久久久久| jlzzjlzz亚洲日本少妇| 欧美日韩成人激情| 国产色综合久久| 亚洲在线视频网站| 国产精品自拍三区| 欧美日韩一区在线| 国产日韩一级二级三级| 亚洲一区二区在线观看视频| 黄色日韩网站视频| 欧美影院一区二区| 国产网站一区二区三区| 亚洲图片一区二区| 大胆欧美人体老妇| 成人一区二区三区视频| 欧美视频一区在线观看| 2023国产精品自拍| 亚洲第一成年网| 五月激情六月综合| 成人午夜免费电影| 欧美一二三在线| 亚洲欧美国产77777| 国产乱一区二区| 69堂成人精品免费视频| 亚洲人成网站影音先锋播放| 国产在线精品一区二区夜色| 欧美日韩久久一区二区| 国产精品麻豆久久久| 久色婷婷小香蕉久久| 在线亚洲欧美专区二区| 国产欧美一二三区| 美女网站色91| 欧美日韩国产综合草草| 亚洲四区在线观看| 成人性生交大片免费| 欧美变态tickle挠乳网站| 亚洲一区电影777| 91在线视频免费观看| 国产日韩欧美精品一区| 国产一区二区在线观看视频| 欧美一级久久久久久久大片| 亚洲国产日韩精品| 一本到不卡免费一区二区| 中文字幕亚洲综合久久菠萝蜜| 国产iv一区二区三区| 久久精品亚洲精品国产欧美kt∨ | 日韩视频一区二区三区在线播放| 亚洲精品国产第一综合99久久| 懂色av中文字幕一区二区三区| 久久午夜色播影院免费高清| 蜜臀av在线播放一区二区三区| 欧美喷水一区二区| 午夜精品在线看| 欧美三片在线视频观看 | 91麻豆swag| 中文字幕一区二区三区在线播放| 国产一区二区三区四区五区入口| 欧美videofree性高清杂交| 久久精品国产秦先生| 欧美精品一区二区在线播放| 麻豆成人av在线| 26uuu久久天堂性欧美| 国产主播一区二区三区| 国产欧美综合色| 国产精品自拍毛片| 精品视频在线免费看| 日韩一级片网站| 色吧成人激情小说| 欧美精品久久99| 欧美日韩国产天堂| 成人中文字幕在线| 日韩 欧美一区二区三区| 亚洲欧洲美洲综合色网| 亚洲欧美国产毛片在线| 国产精品白丝在线| 欧美激情一区在线观看| 国产精品久久三| 天天亚洲美女在线视频| 欧美另类变人与禽xxxxx| 青草av.久久免费一区| 精品动漫一区二区三区在线观看| 国产中文一区二区三区|