【Poco】Poco::LocalDateTime的例子

#include "../tmain.hpp "

void test_datetime()
{
	using Poco::LocalDateTime;
	using Poco::DateTime;
	using Poco::DateTimeFormat;
	using Poco::DateTimeFormatter;
	using Poco::DateTimeParser;

	LocalDateTime now;

	// 2005-01-01T12:00:00+01:00
	// 2005-01-01T11:00:00Z
	std::string str_iso = DateTimeFormatter::format(now, DateTimeFormat::ISO8601_FORMAT);
	PRINT_DEBUG(str_iso);

	// Sat, 01 Jan 2005 12:00:00 +0100
	// Sat, 01 Jan 2005 11:00:00 GMT
	std::string str_http = DateTimeFormatter::format(now, DateTimeFormat::HTTP_FORMAT);
	PRINT_DEBUG(str_http);

	// The date/time format produced by the ANSI C asctime() function.
	// Sat Jan  1 12:00:00 2005
	std::string str_asctime = DateTimeFormatter::format(now, DateTimeFormat::ASCTIME_FORMAT);
	PRINT_DEBUG(str_asctime);

	// A simple, sortable date/time format.
	// 2005-01-01 12:00:00
	std::string str_simple = DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT);
	PRINT_DEBUG(str_simple);

	PRINT_DEBUG(now.year());
	PRINT_DEBUG(now.month());
	PRINT_DEBUG(now.day());
	PRINT_DEBUG(now.dayOfWeek());
	PRINT_DEBUG(now.dayOfYear());
	PRINT_DEBUG(now.julianDay());

	PRINT_DEBUG(DateTimeFormat::WEEKDAY_NAMES[now.dayOfWeek()]);
	PRINT_DEBUG(DateTimeFormat::MONTH_NAMES[now.month() - 1]);

	// 解析时间格式
	DateTime dt;
	int tzd;
	DateTimeParser::parse(DateTimeFormat::ISO8601_FORMAT, str_iso, dt, tzd);
	dt.makeUTC(tzd);
	LocalDateTime ldt(tzd, dt);
}


你可能感兴趣的:(c,String,include)