本文整理汇总了C++中Date::DaysSinceEpoch方法的典型用法代码示例。如果您正苦于以下问题:C++ Date::DaysSinceEpoch方法的具体用法?C++ Date::DaysSinceEpoch怎么用?C++ Date::DaysSinceEpoch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date
的用法示例。
在下文中一共展示了Date::DaysSinceEpoch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetDate
// Move the stellar objects to their positions on the given date.
void System::SetDate(const Date &date)
{
double now = date.DaysSinceEpoch();
for(StellarObject &object : objects)
{
// "offset" is used to allow binary orbits; the second object is offset
// by 180 degrees.
object.angle = Angle(now * object.speed + object.offset);
object.position = object.angle.Unit() * object.distance;
// Because of the order of the vector, the parent's position has always
// been updated before this loop reaches any of its children, so:
if(object.parent >= 0)
object.position += objects[object.parent].position;
if(object.position)
object.angle = Angle(object.position);
if(object.planet)
object.planet->ResetDefense();
}
}
示例2: DaysSinceEpoch
// Get the number of days between the two given dates.
int Date::operator-(const Date &other) const
{
return DaysSinceEpoch() - other.DaysSinceEpoch();
}