mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-04 10:43:19 +00:00
Add a Calendar view on the right side
This commit is contained in:
parent
a80515ff90
commit
f1ac8a42d1
18 changed files with 406 additions and 130 deletions
|
@ -5,6 +5,9 @@
|
|||
*/
|
||||
|
||||
#include "Utils.h"
|
||||
#include <cctype>
|
||||
#include <format>
|
||||
#include <string>
|
||||
|
||||
std::string formatZeroPadding(const int number)
|
||||
{
|
||||
|
@ -14,6 +17,29 @@ std::string formatZeroPadding(const int number)
|
|||
return std::to_string(number);
|
||||
}
|
||||
|
||||
std::string formatDateRelative(const ui::Date &date)
|
||||
{
|
||||
auto todayDate = mirai::Date(std::chrono::system_clock::now());
|
||||
auto relativeDaysDiff = std::chrono::duration_cast<std::chrono::days>(
|
||||
std::chrono::sys_days(SlintDateToMiraiDate(date).toStdChrono()) -
|
||||
std::chrono::sys_days(todayDate.toStdChrono())
|
||||
)
|
||||
.count();
|
||||
|
||||
if (relativeDaysDiff == 0) {
|
||||
return std::string("today");
|
||||
} else if (relativeDaysDiff == 1) {
|
||||
return std::string("tomorrow");
|
||||
}
|
||||
return std::format("in {} days", relativeDaysDiff);
|
||||
};
|
||||
|
||||
std::string capitalize(std::string str)
|
||||
{
|
||||
str[0] = static_cast<char>(toupper(str[0]));
|
||||
return str;
|
||||
};
|
||||
|
||||
std::string SlintDateToStdString(const ui::Date &date)
|
||||
{
|
||||
return std::to_string(date.year) + "-" + formatZeroPadding(date.month) + "-" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue