-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.cpp
82 lines (69 loc) · 2.81 KB
/
time.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
#include <iostream>
#include <time.h>
#include <vector>
#include <string>
#include <fstream>
#include "time.h"
#include "task.h"
#include "fmanip.h"
using namespace std;
//checks for overdue tasks
void updateTime(vector<Task>& input) {
std::ofstream file("overdue.txt", std::ios::app);
time_t ttime = time(0);
struct tm buf;
localtime_s(&buf, &ttime);
time_t current = mktime(&buf);
int taskcount{ 0 };
//checks task in overdue
for (Task i : input) {
if (i.unixDeadline() < current) {
file << i.getName() << "," << i.getDeadline().tm_hour << "," << i.getDeadline().tm_min << "," << i.getDeadline().tm_mday << "," << i.getDeadline().tm_mon << "," << i.getDeadline().tm_year << "," << i.getReminder().tm_hour << "," << i.getReminder().tm_min << "," << i.getReminder().tm_mday << "," << i.getReminder().tm_mon << "," << i.getReminder().tm_year << "," << i.getLocation() << "," << i.getSubject() << "," << i.getUrgent() << "," << i.getNote() << endl;
input.erase(input.begin() + taskcount);
overdueMessage(i);
}
taskcount++;
}
}
//checks if reminders are overdue and produces a reminder notification
void reminderCheck(vector<Task>& input) {
time_t ttime = time(0);
struct tm buf;
localtime_s(&buf, &ttime);
time_t current = mktime(&buf);
for (Task i : input) {
if (i.unixReminder() < current) {
reminderMessage(i);
}
}
}
//reminder notifications
void reminderMessage(Task input) {
string x = "";
cout << "============================================" << endl;
cout << " Task Reminder Alert " << endl;
cout << "Name: " << input.getName() << endl;
cout << "Deadline: " << input.disDeadline() << endl;
cout << "Subject: " << input.getSubject() << endl;
cout << "Location: " << input.getLocation() << endl;
cout << "Note: " << input.getNote() << endl;
cout << "============================================" << endl;
cout << " Enter anything to dismiss " << endl;
cin >> x;
cout << endl;
}
//overdue notifications
void overdueMessage(Task input) {
string x = "";
cout << "============================================" << endl;
cout << " Task Overdue Alert " << endl;
cout << "Name: " << input.getName() << endl;
cout << "Deadline: " << input.disDeadline() << endl;
cout << "Subject: " << input.getSubject() << endl;
cout << "Location: " << input.getLocation() << endl;
cout << "Note: " << input.getNote() << endl;
cout << "============================================" << endl;
cout << " Enter anything to dismiss " << endl;
cin >> x;
cout << endl;
}