本文整理汇总了C++中CTime::AddMonth方法的典型用法代码示例。如果您正苦于以下问题:C++ CTime::AddMonth方法的具体用法?C++ CTime::AddMonth怎么用?C++ CTime::AddMonth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTime
的用法示例。
在下文中一共展示了CTime::AddMonth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s_TestGMT
//.........这里部分代码省略.........
}
}}
// Test TimeZoneOffset (1) -- EST timezone only
{{
CTime tw(2001, 1, 1, 12);
CTime ts(2001, 6, 1, 12);
assert(tw.TimeZoneOffset() / 3600 == -5);
assert(ts.TimeZoneOffset()/3600 == -4);
}}
// Test TimeZoneOffset (2) -- EST timezone only
{{
CTime tw(2001, 6, 1, 12);
CTime ts(2002, 1, 1, 12);
assert(tw.TimeZoneOffset() / 3600 == -4);
assert(ts.TimeZoneOffset() / 3600 == -5);
}}
// Test AdjustTime
{{
CTime::SetFormat("M/D/Y h:m:s");
CTime t("03/11/2007 01:01:00");
CTime tn;
t.SetTimeZonePrecision(CTime::eTZPrecisionDefault);
// GMT
t.SetTimeZone(CTime::eGmt);
tn = t;
tn.AddDay(5);
assert(tn.AsString() == "03/16/2007 01:01:00");
tn = t;
tn.AddDay(40);
assert(tn.AsString() == "04/20/2007 01:01:00");
// Local eNone
t.SetTimeZone(CTime::eLocal);
t.SetTimeZonePrecision(CTime::eNone);
tn = t;
tn.AddDay(5);
assert(tn.AsString() == "03/16/2007 01:01:00");
tn = t;
tn.AddDay(40);
assert(tn.AsString() == "04/20/2007 01:01:00");
//Local eMonth
t.SetTimeZonePrecision(CTime::eMonth);
tn = t;
tn.AddDay(5);
assert(tn.AsString() == "03/16/2007 01:01:00");
tn = t;
tn.AddMonth(-1);
assert(tn.AsString() == "02/11/2007 01:01:00");
tn = t;
tn.AddMonth(+1);
assert(tn.AsString() == "04/11/2007 02:01:00");
// Local eDay
t.SetTimeZonePrecision(CTime::eDay);
tn = t;
tn.AddDay(-1);
assert(tn.AsString() == "03/10/2007 01:01:00");
tn.AddDay();
assert(tn.AsString() == "03/11/2007 01:01:00");
tn = t;
tn.AddDay();
assert(tn.AsString() == "03/12/2007 02:01:00");
// Local eHour
t.SetTimeZonePrecision(CTime::eHour);
tn = t;
tn.AddHour(-3);
CTime te = t;
te.AddHour(3);
assert(tn.AsString() == "03/10/2007 22:01:00");
assert(te.AsString() == "03/11/2007 05:01:00");
CTime th = tn;
th.AddHour(49);
assert(th.AsString() == "03/13/2007 00:01:00");
tn = "11/04/2007 00:01:00";
tn.SetTimeZonePrecision(CTime::eHour);
te = tn;
tn.AddHour(-3);
te.AddHour(9);
assert(tn.AsString() == "11/03/2007 21:01:00");
assert(te.AsString() == "11/04/2007 08:01:00");
th = tn;
th.AddHour(49);
assert(th.AsString() == "11/05/2007 21:01:00");
tn = "11/04/2007 09:01:00";
tn.SetTimeZonePrecision(CTime::eHour);
te = tn;
tn.AddHour(-10);
te.AddHour(+10);
assert(tn.AsString() == "11/04/2007 00:01:00");
assert(te.AsString() == "11/04/2007 19:01:00");
}}
}