/*
 * 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 "Utils.h"

std::string formatZeroPadding(const int number)
{
	if (number < 10) {
		return "0" + std::to_string(number);
	}
	return std::to_string(number);
}

std::string SlintDateToStdString(const Date &date)
{
	return std::to_string(date.year) + "-" + formatZeroPadding(date.month) + "-" +
		   formatZeroPadding(date.day);
}

mirai::Date SlintDateToMiraiDate(const Date &date)
{
	return mirai::Date(
		date.year, static_cast<unsigned>(date.month), static_cast<unsigned>(date.day)
	);
}

Date MiraiDateToSlintDate(const mirai::Date &date)
{
	return {
		.year = date.year,
		.month = static_cast<int>(date.month),
		.day = static_cast<int>(date.day),
	};
}

Time MiraiTimeToSlintTime(const mirai::Time &time)
{
	return {.hour = time.hour, .minute = time.minute, .second = 0};
}

mirai::Time SlintTimeToMiraiTime(const Time &time)
{
	return {.hour = time.hour, .minute = time.minute};
}
