每天在红宝石中设定时间

时间:2017-09-08 11:52:56

标签: ruby time

我做了一些测试时间。这是代码:

struct Multiple;

struct Number
{
    Number(double val)
        : m_Val(val)
    {}

    friend double operator+(const Multiple& left, const Number& right);
    friend Multiple operator*(const Number& left, const Number& right);

    private:
    double m_Val;

};

struct Multiple
{
    Multiple(double left, double right)
      : m_left(left),
        m_right(right)
    {}

    friend double operator+(const Multiple& left, const Number& right);

    private:
    double m_left;
    double m_right;
};

Multiple operator*(const Number& left, const Number& right)
{
    return Multiple(left.m_Val, right.m_Val);
}

double operator+(const Multiple& a, const Number& b)
{
    return a.m_left * (a.m_right + b.m_Val);
}


void main()
{
    Number a(3);
    Number b(1);
    Number c(2);

    double d = a * b + c;
    // d = 9 (not 5)
}

但我不知道如何为每天创造固定时间。我需要每天改变它。给我一些提示?

1 个答案:

答案 0 :(得分:0)

t = DateTime.parse("14:30").to_time

上面将构建今天下午2:30的时间实例。