-
Notifications
You must be signed in to change notification settings - Fork 0
/
DateFilter.cpp
100 lines (90 loc) · 2.68 KB
/
DateFilter.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
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
/**
* CS3307 Team Banana
*
* DateFilter is a tool used when filtering data by date. It handles comparing data to the date range
* and returning whether or not the data point should be included in the filtered summary
*/
#include "DateFilter.h"
/**
* Constructs the datefilter object. Fills the variables earliestDate and latestDate with the
* values inputed into the constructor
*
* @param earliestYear Value to be sotred in the objects variable earliestDate
* @param latestYear Value to be sotred in the objects variable latestDate
*/
DateFilter::DateFilter(int earliestYear, int latestYear): earliestDate(earliestYear), latestDate(latestYear) {
;
}
/**
* Takes a Grants and Funding record and returns whether or not it is within the date filter
*
* @param record The record that the function is checking
*
* @return Returns 0 if record is withing filter and 1 otherwise
*/
int DateFilter::filter(ProcessedGrantsAndFundingRecord& record){
std::string date = record.getStartDate();
if (date.compare("") == 0)
return 1;
std::istringstream yearStream(date.substr(0,4));
int year;
if (!(yearStream >> year))
return 1;
if (year >= earliestDate)
if (year <= latestDate)
return 0;
return 1;
}
/**
* Takes a Publication record and returns whether or not it is within the date filter
*
* @param record The record that the function is checking
*
* @return Returns 0 if record is withing filter and 1 otherwise
*/
int DateFilter::filter(ProcessedPublicationRecord& record){
std::string date = record.getStatusDate();
if (date.compare("") == 0)
return 1;
std::istringstream yearStream(date.substr(0,4));
int year;
if (!(yearStream >> year))
return 1;
if (year >= earliestDate)
if (year <= latestDate)
return 0;
return 1;
}
/**
* Takes a Presentation record and returns whether or not it is within the date filter
*
* @param record The record that the function is checking
*
* @return Returns 0 if record is withing filter and 1 otherwise
*/
int DateFilter::filter(ProcessedPresentationRecord& record){
std::string date = record.getDate();
if (date.compare("") == 0)
return 1;
std::istringstream yearStream(date.substr(0,4));
int year;
if (!(yearStream >> year))
return 1;
if (year >= earliestDate)
if (year <= latestDate)
return 0;
return 1;
}
int DateFilter::filter(ProcessedTeachingRecord& record){
std::string date = record.getStartDate();
if (date.compare("") == 0)
return 1;
std::istringstream yearStream(date.substr(0,4));
int year;
if (!(yearStream >> year))
return 1;
if (year >= earliestDate)
if (year <= latestDate)
return 0;
return 1;
}