-
Notifications
You must be signed in to change notification settings - Fork 0
/
Base.cpp
57 lines (51 loc) · 1.25 KB
/
Base.cpp
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
#include "Base.hpp"
Base::Base(){
name = "";
description = "";
datestr = "";
date = convert_date();
}
Base::Base(std::string name, std::string description,std::string date){
this->name = name;
this->description = description;
this->datestr = date;
this->date = convert_date();
}
Base::~Base(){};
void Base::setName(std::string name){
this->name = name;
};
void Base::setDescription(std::string description){
this->description = description;
};
std::string Base::getName(){
return name;
};
std::string Base::getDescription(){
return description;
};
std::string Base::get_date() {
if (datestr == "") {
return " ";
}
else
return datestr;
}
void Base::set_date(std::string d){
this->datestr = d;
}
Date Base::convert_date(){
if (datestr.size() == 0) {
return Date(0,0,0); // if datestr is empty, return 0/0/0
}
else {
std::string::size_type sz; // alias of size_t
int m = std::stoi(datestr.substr(0,2), &sz);
int d = std::stoi(datestr.substr(3,2), &sz);
int y = std::stoi(datestr.substr(6,4), &sz);
return Date(m,d,y);
}
}
Date Base::get_date_obj() {
return date;
}