本文整理汇总了C++中my_facet::get_time方法的典型用法代码示例。如果您正苦于以下问题:C++ my_facet::get_time方法的具体用法?C++ my_facet::get_time怎么用?C++ my_facet::get_time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类my_facet
的用法示例。
在下文中一共展示了my_facet::get_time方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
std::ios ios(0);
std::ios_base::iostate err;
std::tm t;
{
const my_facet f(LOCALE_en_US_UTF_8, 1);
const wchar_t in[] = L"13:14:15";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
assert(t.tm_hour == 13);
assert(t.tm_min == 14);
assert(t.tm_sec == 15);
assert(err == std::ios_base::eofbit);
}
{
const my_facet f(LOCALE_fr_FR_UTF_8, 1);
const wchar_t in[] = L"13:14:15";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
assert(t.tm_hour == 13);
assert(t.tm_min == 14);
assert(t.tm_sec == 15);
assert(err == std::ios_base::eofbit);
}
{
const my_facet f(LOCALE_ru_RU_UTF_8, 1);
const wchar_t in[] = L"13:14:15";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
assert(t.tm_hour == 13);
assert(t.tm_min == 14);
assert(t.tm_sec == 15);
assert(err == std::ios_base::eofbit);
}
{
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
const wchar_t in[] = L"13:14:15";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
assert(t.tm_hour == 13);
assert(t.tm_min == 14);
assert(t.tm_sec == 15);
assert(err == std::ios_base::eofbit);
}
}
示例2: main
int main()
{
const my_facet f(1);
std::ios ios(0);
std::ios_base::iostate err;
std::tm t;
{
const char in[] = "0:0:0";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+sizeof(in)-1);
assert(t.tm_hour == 0);
assert(t.tm_min == 0);
assert(t.tm_sec == 0);
assert(err == std::ios_base::eofbit);
}
{
const char in[] = "23:59:60";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+sizeof(in)-1);
assert(t.tm_hour == 23);
assert(t.tm_min == 59);
assert(t.tm_sec == 60);
assert(err == std::ios_base::eofbit);
}
{
const char in[] = "24:59:60";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+2);
assert(t.tm_hour == 0);
assert(t.tm_min == 0);
assert(t.tm_sec == 0);
assert(err == std::ios_base::failbit);
}
{
const char in[] = "23:60:60";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+5);
// assert(t.tm_hour == 0);
// assert(t.tm_min == 0);
// assert(t.tm_sec == 0);
assert(err == std::ios_base::failbit);
}
{
const char in[] = "23:59:61";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+8);
// assert(t.tm_hour == 0);
// assert(t.tm_min == 0);
// assert(t.tm_sec == 0);
assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
}
{
const char in[] = "2:43:221";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+7);
assert(t.tm_hour == 2);
assert(t.tm_min == 43);
assert(t.tm_sec == 22);
assert(err == std::ios_base::goodbit);
}
{
const char in[] = "2.43:221";
err = std::ios_base::goodbit;
t = std::tm();
I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
assert(i.base() == in+1);
// assert(t.tm_hour == 0);
// assert(t.tm_min == 0);
// assert(t.tm_sec == 0);
assert(err == std::ios_base::failbit);
}
}