-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDate.cpp
More file actions
executable file
·31 lines (23 loc) · 786 Bytes
/
Date.cpp
File metadata and controls
executable file
·31 lines (23 loc) · 786 Bytes
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
//
// Created by nikang on 12/22/16.
//
#include "Date.h"
Date::Date(int month, int day, int year) : month(month), day(day), year(year) {}
void Date::set_date(int month, int day, int year) {
this->day = day, this->month = month, this->year = year;
}
string Date::display() {
return this->name[month - 1] + " " + std::to_string(this->day) + "," + to_string(year) + " \n";
}
//return date from year begging
int Date::days_so_far() {
int total = 0;
total += (30 * (this->month - 1));
total += this->day;
return (total);
}
int Date::sub(Date *date) {
return abs(this->days_so_far() - date->days_so_far());
}
const string Date::name[] = {"Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov",
"Dec"};