当前位置: 首页>>代码示例>>C++>>正文


C++ RoughTime类代码示例

本文整理汇总了C++中RoughTime的典型用法代码示例。如果您正苦于以下问题:C++ RoughTime类的具体用法?C++ RoughTime怎么用?C++ RoughTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RoughTime类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FromMinuteOfDayChecked

gcc_const
static inline RoughTime
operator+(RoughTime t, RoughTimeDelta delta)
{
  if (!t.IsValid())
    return t;

  int value = t.GetMinuteOfDay() + delta.AsMinutes();
  return RoughTime::FromMinuteOfDayChecked(value);
}
开发者ID:MindMil,项目名称:XCSoar,代码行数:10,代码来源:RoughTime.hpp

示例2: SetAttribute

void
WritableDataNode::SetAttribute(const TCHAR *name, RoughTime value)
{
  if (!value.IsValid())
    /* no-op */
    return;

  StaticString<8> buffer;
  buffer.UnsafeFormat(_T("%02u:%02u"), value.GetHour(), value.GetMinute());
  SetAttribute(name, buffer);
}
开发者ID:kwtskran,项目名称:XCSoar,代码行数:11,代码来源:DataNode.cpp

示例3: Main

static void
Main()
{
  RoughTime value = RoughTime::Invalid();
  const RoughTimeDelta time_zone = RoughTimeDelta::FromMinutes(0);
  if (!TimeEntryDialog(_T("The caption"), value, time_zone, true))
    return;

  if (value.IsValid())
    printf("%02u:%02u\n", value.GetHour(), value.GetMinute());
  else
    printf("invalid\n");
}
开发者ID:CnZoom,项目名称:XcSoarPull,代码行数:13,代码来源:RunTimeEntry.cpp

示例4: SecondsUntil

gcc_pure
static unsigned
SecondsUntil(unsigned now, RoughTime until)
{
  int d = until.GetMinuteOfDay() * 60 - now;
  if (d < 0)
    d += 24 * 60 * 60;
  return d;
}
开发者ID:Adrien81,项目名称:XCSoar,代码行数:9,代码来源:Task.cpp

示例5: assert

void
DigitEntry::SetValue(RoughTime value)
{
    assert(length == 4);
    assert(columns[0].type == Column::Type::HOUR);
    assert(columns[1].type == Column::Type::COLON);
    assert(columns[2].type == Column::Type::DIGIT6);
    assert(columns[3].type == Column::Type::DIGIT);

    if (value.IsValid()) {
        columns[0].value = value.GetHour();
        columns[2].value = value.GetMinute() / 10;
        columns[3].value = value.GetMinute() % 10;
        valid = true;
    } else {
        columns[0].value = 0;
        columns[2].value = 0;
        columns[3].value = 0;
        valid = false;
    }

    Invalidate();
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:23,代码来源:DigitEntry.cpp

示例6: HasEnded

 constexpr bool HasEnded(RoughTime now) const {
   /* if end is invalid, the time span is open-ended, i.e. it will
      never end */
   return end.IsValid() && now >= end;
 }
开发者ID:MindMil,项目名称:XCSoar,代码行数:5,代码来源:RoughTime.hpp

示例7: HasBegun

 constexpr bool HasBegun(RoughTime now) const {
   /* if start is invalid, we assume the time span has always already
      begun */
   return !start.IsValid() || now >= start;
 }
开发者ID:MindMil,项目名称:XCSoar,代码行数:5,代码来源:RoughTime.hpp

示例8: main

int main(int argc, char **argv)
{
  plan_tests(77);

  RoughTime a = RoughTime::Invalid();
  ok1(!a.IsValid());

  a = RoughTime(12, 1);
  ok1(a.IsValid());
  ok1(a.GetHour() == 12);
  ok1(a.GetMinute() == 1);
  ok1(a.GetMinuteOfDay() == 12 * 60 + 1);

  /* compare a RoughTime with itself */
  ok1(a == a);
  ok1(!(a != a));
  ok1(a <= a);
  ok1(a >= a);
  ok1(!(a < a));
  ok1(!(a > a));

  /* compare a RoughTime with another one */
  RoughTime b(11, 59);
  ok1(b.IsValid());
  ok1(a != b);
  ok1(!(a == b));
  ok1(!(a <= b));
  ok1(a >= b);
  ok1(!(a < b));
  ok1(a > b);
  ok1(b != a);
  ok1(!(b == a));
  ok1(b <= a);
  ok1(!(b >= a));
  ok1(b < a);
  ok1(!(b > a));

  /* test RoughTimeSpan::IsInside() */
  RoughTimeSpan s = RoughTimeSpan::Invalid();
  ok1(!s.IsDefined());
  ok1(s.IsInside(a));
  ok1(s.IsInside(b));

  s = RoughTimeSpan(RoughTime(12, 0), RoughTime::Invalid());
  ok1(s.IsDefined());
  ok1(s.IsInside(a));
  ok1(!s.IsInside(b));

  s = RoughTimeSpan(RoughTime::Invalid(), RoughTime(12, 0));
  ok1(s.IsDefined());
  ok1(!s.IsInside(a));
  ok1(s.IsInside(b));

  s = RoughTimeSpan(RoughTime(12, 0), RoughTime(12, 1));
  ok1(s.IsDefined());
  ok1(!s.IsInside(a));
  ok1(!s.IsInside(b));

  s = RoughTimeSpan(RoughTime(12, 0), RoughTime(12, 30));
  ok1(s.IsDefined());
  ok1(s.IsInside(a));
  ok1(!s.IsInside(b));

  /* test midnight wraparound */
  a = RoughTime(0, 0);
  b = RoughTime(23, 59);
  ok1(b.IsValid());
  ok1(a != b);
  ok1(!(a == b));
  ok1(!(a <= b));
  ok1(a >= b);
  ok1(!(a < b));
  ok1(a > b);
  ok1(b != a);
  ok1(!(b == a));
  ok1(b <= a);
  ok1(!(b >= a));
  ok1(b < a);
  ok1(!(b > a));

  RoughTime c(22, 0);
  RoughTime d(2, 0);
  s = RoughTimeSpan(RoughTime(23, 0), RoughTime::Invalid());
  ok1(s.IsDefined());
  ok1(s.IsInside(a));
  ok1(s.IsInside(b));
  ok1(!s.IsInside(c));
  ok1(s.IsInside(d));

  s = RoughTimeSpan(RoughTime::Invalid(), RoughTime(1, 0));
  ok1(s.IsDefined());
  ok1(s.IsInside(a));
  ok1(s.IsInside(b));
  ok1(s.IsInside(c));
  ok1(!s.IsInside(d));

  s = RoughTimeSpan(RoughTime(23, 1), RoughTime(0, 30));
  ok1(s.IsDefined());
  ok1(s.IsInside(a));
  ok1(s.IsInside(b));
//.........这里部分代码省略.........
开发者ID:MindMil,项目名称:XCSoar,代码行数:101,代码来源:TestRoughTime.cpp

示例9: IsDefined

 constexpr bool IsDefined() const {
   return start.IsValid() || end.IsValid();
 }
开发者ID:MindMil,项目名称:XCSoar,代码行数:3,代码来源:RoughTime.hpp


注:本文中的RoughTime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。