-
-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathcookie_time.cpp
More file actions
55 lines (44 loc) · 1.56 KB
/
cookie_time.cpp
File metadata and controls
55 lines (44 loc) · 1.56 KB
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
/**
* File: cookie_time.cpp
* Author: Giuseppe Persico
*/
#include "cookie_time.h"
using std::ostringstream;
// Implementation of constructor with parameters.
curl::cookie_time::cookie_time(const unsigned int hour, const unsigned int minutes,
const unsigned int seconds) {
this->set_hour(hour)->set_minutes(minutes)->set_seconds(seconds);
}
// Implementation of set_hour method.
curl::cookie_time *curl::cookie_time::set_hour(unsigned int _hour) NOEXCEPT {
this->hour = _hour > 23 ? 0 : _hour;
return this;
}
// Implementation of set_minutes method.
curl::cookie_time *curl::cookie_time::set_minutes(unsigned int _minutes) NOEXCEPT {
this->minutes = _minutes > 59 ? 0 : _minutes;
return this;
}
// Implementation of set_seconds method.
curl::cookie_time *curl::cookie_time::set_seconds(unsigned int _seconds) NOEXCEPT {
this->seconds = _seconds > 59 ? 0 : _seconds;
return this;
}
// Implementation of get_hour method.
unsigned int curl::cookie_time::get_hour() const NOEXCEPT {
return this->hour;
}
// Implementation of get_minutes method.
unsigned int curl::cookie_time::get_minutes() const NOEXCEPT {
return this->minutes;
}
// Implementation of get_seconds method.
unsigned int curl::cookie_time::get_seconds() const NOEXCEPT {
return this->seconds;
}
// Implementation of get_formatted method.
std::string curl::cookie_time::get_formatted() const NOEXCEPT {
ostringstream stream;
stream<<this->get_hour()<<":"<<this->get_minutes()<<":"<<this->get_seconds()<<" GMT";
return stream.str();
}