-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.cpp
More file actions
26 lines (21 loc) · 717 Bytes
/
Task.cpp
File metadata and controls
26 lines (21 loc) · 717 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
#include "Task.h"
Task::Task(const std::string& name, const std::string& details)
: name(name), details(details), timeSpent(0) {}
void Task::addTimeSpent(std::chrono::minutes time) {
timeSpent += time;
}
std::string Task::getName() const { return name; }
std::string Task::getDetails() const { return details; }
std::chrono::minutes Task::getTimeSpent() const { return timeSpent; }
nlohmann::json Task::toJson() const {
return {
{"name", name},
{"details", details},
{"time_spent", timeSpent.count()}
};
}
Task Task::fromJson(const nlohmann::json& j) {
Task task(j["name"], j["details"]);
task.timeSpent = std::chrono::minutes(j["time_spent"]);
return task;
}