void testToLocalTime()
	{
		const vmime::datetime date
			(2005, 12, 2, 12, 34, 56, -120); // GMT-2

		const vmime::datetime local =
			datetimeUtils::toLocalTime(date, 120); // GMT+2

		VASSERT_EQ("1", 2005, local.getYear());
		VASSERT_EQ("2",   12, local.getMonth());
		VASSERT_EQ("3",    2, local.getDay());
		VASSERT_EQ("4",   16, local.getHour());
		VASSERT_EQ("5",   34, local.getMinute());
		VASSERT_EQ("6",   56, local.getSecond());
		VASSERT_EQ("7",  120, local.getZone());
	}
	void testToUniversalTime()
	{
		const vmime::datetime local
			(2005, 12, 2, 12, 34, 56, -789);

		const vmime::datetime gmt =
			datetimeUtils::toUniversalTime(local);

		// 789 is 13 hours, 9 minutes later
		VASSERT_EQ("1", 2005, gmt.getYear());
		VASSERT_EQ("2",   12, gmt.getMonth());
		VASSERT_EQ("3",    3, gmt.getDay());
		VASSERT_EQ("4",    1, gmt.getHour());
		VASSERT_EQ("5",   43, gmt.getMinute());
		VASSERT_EQ("6",   56, gmt.getSecond());
		VASSERT_EQ("7",    0, gmt.getZone());
	}
Пример #3
0
time_t converse_date(vmime::datetime date) {
	struct tm* c_date = new tm;		
	c_date->tm_year = date.getYear() - 1900; //returns the year (since 1900)
	c_date->tm_mon = date.getMonth() - 1; //returns the month (January = 0)sd
	c_date->tm_mday = date.getDay(); //returns the day of the month
	c_date->tm_hour =  date.getHour();
	c_date->tm_min =  date.getMinute();
	c_date->tm_sec =  date.getSecond();
	time_t letter_date = mktime(c_date);
	delete c_date;
	return letter_date;

}