ClickHouse/base/common/tests/date_lut_default_timezone.cpp

32 lines
829 B
C++
Raw Normal View History

#include <iostream>
#include <common/DateLUT.h>
#include <Poco/Exception.h>
2020-03-18 03:27:32 +00:00
int main(int, char **)
{
try
{
const auto & date_lut = DateLUT::instance();
std::cout << "Detected default timezone: `" << date_lut.getTimeZone() << "'" << std::endl;
2020-03-09 01:50:33 +00:00
time_t now = time(nullptr);
std::cout << "Current time: " << date_lut.timeToString(now)
<< ", UTC: " << DateLUT::instance("UTC").timeToString(now) << std::endl;
}
catch (const Poco::Exception & e)
{
std::cerr << e.displayText() << std::endl;
return 1;
}
catch (std::exception & e)
{
std::cerr << "std::exception: " << e.what() << std::endl;
return 2;
}
catch (...)
{
std::cerr << "Some exception" << std::endl;
return 3;
}
return 0;
}