mirai/external/mirai-core/src/Day.cpp

61 lines
1.1 KiB
C++
Raw Normal View History

2024-08-16 21:35:12 +02:00
/*
* Mirai. Copyright (C) 2024 Vyn
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
#include "Day.h"
2024-10-11 16:26:13 +02:00
#include "Task.h"
2024-08-16 21:35:12 +02:00
#include <algorithm>
2024-10-11 16:26:13 +02:00
#include <stdexcept>
2024-08-16 21:35:12 +02:00
namespace mirai
{
2024-10-11 16:26:13 +02:00
int Day::id() const
2024-08-16 21:35:12 +02:00
{
2024-10-11 16:26:13 +02:00
return dayData_.id;
2024-08-16 21:35:12 +02:00
}
2024-10-11 16:26:13 +02:00
int Day::sourceId() const
2024-08-16 21:35:12 +02:00
{
2024-10-11 16:26:13 +02:00
return data_->id;
2024-08-16 21:35:12 +02:00
}
2024-10-11 16:26:13 +02:00
Date Day::date() const
2024-08-16 21:35:12 +02:00
{
2024-10-11 16:26:13 +02:00
return dayData_.date;
2024-08-16 21:35:12 +02:00
}
2024-10-11 16:26:13 +02:00
std::vector<Task> Day::tasks()
2024-08-16 21:35:12 +02:00
{
2024-10-11 16:26:13 +02:00
auto tasksData = data_->getTasksByDayId(id());
std::vector<Task> tasks;
std::transform(
tasksData.begin(), tasksData.end(), std::back_inserter(tasks),
[&](const TaskData &taskData) {
return Task{data_, taskData};
}
2024-08-16 21:35:12 +02:00
);
2024-10-11 16:26:13 +02:00
return tasks;
2024-08-16 21:35:12 +02:00
}
2024-10-11 16:26:13 +02:00
std::vector<Event> Day::events()
2024-08-16 21:35:12 +02:00
{
2024-10-11 16:26:13 +02:00
auto eventsData = data_->getEventsByDate(dayData_.date);
std::vector<Event> events;
std::transform(
eventsData.begin(), eventsData.end(), std::back_inserter(events),
[&](const EventData &eventData) {
return Event{data_, eventData};
}
2024-10-11 16:26:13 +02:00
);
return events;
}
2024-10-11 16:26:13 +02:00
void Day::mergeDay(const Day &otherDay)
{
2024-10-11 16:26:13 +02:00
throw std::runtime_error("Not implemented yet");
}
2024-08-16 21:35:12 +02:00
} // namespace mirai