30#include <rtl/character.hxx>
38 ::std::wstring ws8601DateTime(isoDate);
44 if (ws8601DateTime.length() > 19)
46 ws8601DateTime.erase(19, ::std::basic_string<char>::npos);
49 if ( ws8601DateTime.length() == 19 )
53 DateTime.wYear =
static_cast<unsigned short>(strtol( asDateTime.substr( 0, 4 ).c_str(),
nullptr, 10 ));
54 DateTime.wMonth =
static_cast<unsigned short>(strtol( asDateTime.substr( 5, 2 ).c_str(),
nullptr, 10 ));
56 DateTime.wDay =
static_cast<unsigned short>(strtol( asDateTime.substr( 8, 2 ).c_str(),
nullptr, 10 ));
57 DateTime.wHour =
static_cast<unsigned short>(strtol( asDateTime.substr( 11,2 ).c_str(),
nullptr, 10 ));
58 DateTime.wMinute =
static_cast<unsigned short>(strtol( asDateTime.substr( 14,2 ).c_str(),
nullptr, 10 ));
59 DateTime.wSecond =
static_cast<unsigned short>(strtol( asDateTime.substr( 17,2 ).c_str(),
nullptr, 10 ));
64 int DateSize = GetDateFormatW(
65 LOCALE_SYSTEM_DEFAULT,
73 ws8601DateTime.assign(DateBuffer);
80 int TimeSize = GetTimeFormatW(
81 LOCALE_SYSTEM_DEFAULT,
90 ws8601DateTime.append(L
" ");
91 ws8601DateTime.append(TimeBuffer);
97 return ws8601DateTime;
114 std::wstring minutes;
115 std::wstring seconds;
119 for (
const auto& w_ch : iso8601duration)
121 if (rtl::isAsciiDigit(w_ch))
127 if (w_ch == L
'D' || w_ch == L
'd')
129 else if (w_ch == L
'H' || w_ch == L
'h')
131 else if (w_ch == L
'M' || w_ch == L
'm')
133 else if (w_ch == L
'S' || w_ch == L
's')
140 if (days.length() > 0)
142 int h = (_wtoi(days.c_str()) * 24) + _wtoi(hours.c_str());
148 std::wostringstream oss;
149 oss << std::setw(2) << std::setfill(
wchar_t(
'0')) << hours << L
":" <<
150 std::setw(2) << std::setfill(
wchar_t(
'0')) << minutes << L
":" <<
151 std::setw(2) << std::setfill(
wchar_t(
'0')) << seconds;
std::wstring iso8601_duration_to_local_duration(const std::wstring &iso8601duration)
std::wstring iso8601_date_to_local_date(const std::wstring &isoDate)
static std::string WStringToString(const std::wstring &String, int codepage)
static std::wstring StringToWString(const std::string &String, int codepage)