本文整理汇总了C++中NPT_TimeStamp::SetSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ NPT_TimeStamp::SetSeconds方法的具体用法?C++ NPT_TimeStamp::SetSeconds怎么用?C++ NPT_TimeStamp::SetSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPT_TimeStamp
的用法示例。
在下文中一共展示了NPT_TimeStamp::SetSeconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: now_local
/*----------------------------------------------------------------------
| TestMisc
+---------------------------------------------------------------------*/
static void
TestMisc()
{
NPT_DateTime date;
NPT_TimeStamp ts;
NPT_String s;
NPT_System::GetCurrentTimeStamp(ts);
SHOULD_SUCCEED(date.FromTimeStamp(ts, false));
s = date.ToString(NPT_DateTime::FORMAT_W3C);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_ANSI);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_RFC_1036);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_RFC_1123);
NPT_Console::OutputF("%s\n", s.GetChars());
SHOULD_SUCCEED(date.FromTimeStamp(ts, true));
s = date.ToString(NPT_DateTime::FORMAT_W3C);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_ANSI);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_RFC_1036);
NPT_Console::OutputF("%s\n", s.GetChars());
s = date.ToString(NPT_DateTime::FORMAT_RFC_1123);
NPT_Console::OutputF("%s\n", s.GetChars());
ts = 0.0;
SHOULD_SUCCEED(date.FromTimeStamp(ts, false));
s = date.ToString(NPT_DateTime::FORMAT_W3C);
SHOULD_EQUAL_S(s.GetChars(), "1970-01-01T00:00:00Z");
s = date.ToString(NPT_DateTime::FORMAT_ANSI);
SHOULD_EQUAL_S(s.GetChars(), "Thu Jan 1 00:00:00 1970");
s = date.ToString(NPT_DateTime::FORMAT_RFC_1036);
SHOULD_EQUAL_S(s.GetChars(), "Thursday, 01-Jan-70 00:00:00 GMT");
s = date.ToString(NPT_DateTime::FORMAT_RFC_1123);
SHOULD_EQUAL_S(s.GetChars(), "Thu, 01 Jan 1970 00:00:00 GMT");
ts.SetSeconds(0xFFFFFFFF);
SHOULD_SUCCEED(date.FromTimeStamp(ts, false));
s = date.ToString(NPT_DateTime::FORMAT_W3C, false);
SHOULD_EQUAL_S(s.GetChars(), "2106-02-07T06:28:15Z");
NPT_TimeStamp now;
NPT_System::GetCurrentTimeStamp(now);
NPT_DateTime now_local(now, true);
NPT_DateTime now_utc(now, false);
SHOULD_EQUAL_I(now_utc.m_TimeZone, 0);
NPT_TimeStamp ts1, ts2;
now_local.ToTimeStamp(ts1);
now_utc.ToTimeStamp(ts2);
SHOULD_EQUAL_I((int)ts1.ToSeconds(), (int)ts2.ToSeconds());
ts.SetSeconds(0);
NPT_DateTime d1(ts);
ts.SetSeconds(ts.ToSeconds()-3600);
NPT_DateTime d2(ts);
d1.ToTimeStamp(ts1);
d2.ToTimeStamp(ts2);
SHOULD_EQUAL_I((int)ts1.ToSeconds(), (int)ts2.ToSeconds()+3600);
}