-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time.h
100 lines (89 loc) · 2.27 KB
/
Time.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <ostream>
/**
* @brief Time container with minutes and hours
*/
class Time
{
private:
unsigned hour, minute;
public:
/**
* @brief Construct a new Time object
*
* @param hour
* @param minute
*/
Time(const unsigned &hour, const unsigned &minute);
/**
* @brief Construct a new Time object
*
* @param minutes - number of minutes
*/
Time(const unsigned &minutes);
/**
* @brief Construct a new Time object
*
* \note sets the time to 0 hours and 0 minutes
*/
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;
/**
* @brief Adds time to one timer constructing a new object and returning it
*
* @param minutes minutes to add
* @return Time return time
*/
Time operator+(unsigned minutes) const;
/**
* @brief Reduces time to one timer contructing a new object and returning it
*
* @param minutes minutes to reduce
* @return Time return time
*/
Time operator-(unsigned minutes) const;
/**
* @brief Subtracts 2 times
*
* @param rhs right hand side time
* @return Time Subtraction between \p this and \p rhs
*/
Time operator-(const Time &rhs) const;
/**
* @brief Get the Hour object
*
* @return unsigned hour
*/
unsigned getHour() const;
/**
* @brief Get the Minute object
*
* @return unsigned minute
*/
unsigned getMinute() const;
/**
* @brief Get the Total Minutes object
*
* @return unsigned hour * 60 + minutes
*/
unsigned getTotalMinutes() const;
/**
* @brief Sends to an output stream the information of a Time object
*
* @param os output stream
* @param time time object
* @return std::ostream& return the output stream
*/
friend std::ostream &operator<<(std::ostream &os, const Time &time);
/**
* @brief Converts the time object to a formated string
*
* @return std::string formated string
*/
std::string to_string() const;
};