3.4 Time

The Time class can store and handle time on a hour, minute, second, nano-second basis.


Synopsis


  #include <lyric/Time.hpp>
  
  class Time
  {
  public:
    enum When { Now };
    ~Time ();
    Time ();
    Time (uint8 hour, uint8 min, uint8 sec, uint32 nsec);
    Time (When when);
    Time (const Time& time);
    Time& operator = (const Time& time);
    bool operator == (const Time& time) const;
    bool operator != (const Time& time) const;
    bool operator < (const Time& time) const;
    bool operator > (const Time& time) const;
    bool operator <= (const Time& time) const;
    bool operator >= (const Time& time) const;
    int32 operator += (const Time& time);
    int32 operator -= (const Time& time);
    uint8 hour () const;
    uint8 min () const;
    uint8 minute () const;
    uint8 sec () const;
    uint8 second () const;
    uint32 nsec () const;
    uint32 nanosec () const;
    uint32 nanosecond () const;
    void set (When when);
  };


Description


˜Time ()
Destroys this time. Releases all used resources to the system.

Time ()
Constructs this time with all values set to zero.

Time (uint8 hour, uint8 min, uint8 sec, uint32 nsec)
Constructs this time with the given hour, minute, second, and nsec (nano-second). No consistency check is done. This constructor assumes that the minute and second arguments are in the [0...59] range.

Time (Time::When when)
Constructs this time from the given when argument. Currently when can only be Time::Now, which sets this time to the current time.

Time (const Time& time)
Constructs this time from the given time. All data stored in time are cloned into this.

Time& operator = (const Time& time)
Assigns the rvalue time to this time, and returns a reference to this for assignment operations chaining. All data stored in time are cloned into this.

bool operator == (const Time& time) const
Returns true if this time and the rvalue time store the same values, false if not.

bool operator != (const Time& time) const
Returns true if this time and the rvalue time do not store the same values, false if they do.

bool operator < (const Time& time) const
Returns true if this time is smaller than (e.g: precedes) the rvalue time, false if not.

bool operator > (const Time& time) const
Returns true if this time is larger than (e.g: follows) the rvalue time, false if not.

bool operator <= (const Time& time) const
Returns true if this time is smaller than (e.g: precedes) or equal to the rvalue time, false if not.

bool operator >= (const Time& time) const
Returns true if this time is larger than (e.g: follows) or equal to the rvalue time, false if not.

int32 operator += (const Time& time)
Adds the rvalue time to this time. The returned integer is the reminder in number of days that results from the addition. The result in this time is rounded to fit in the range [0...23], thus the reminder.

int32 operator -= (const Time& time)
Subtracts the rvalue time from this time. The returned integer is the reminder in number of days that results from the subtraction. The result in this time is rounded to fit in the range [0...23], thus the reminder.

uint8 hour () const
Returns the hour part stored in this time.

uint8 min () const
uint8 minute () const
Returns the minute part stored in this time.

uint8 sec () const
uint8 second () const
Returns the second part stored in this time.

uint32 nsec () const
uint32 nanosec () const
uint32 nanosecond () const
Returns the nano-second part stored in this time.

void set (When when)
Sets this time to a given when. Currently when can only take the value Time::Now, which sets this time to the current time.