1
0
This repository has been archived on 2023-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
budet-cho-bot/Budet-cho-bot/Utility.cs
2023-07-25 19:06:46 +08:00

25 lines
763 B
C#

using Newtonsoft.Json.Linq;
namespace Discord_Bot;
public static class Utility
{
public static string ParseMessage(string message)
{
var time = message.Split(":");
if (time.Length != 2)
{
throw new ArgumentException("Время неправильное. Хуйня твоё время");
return null;
}
var now = DateTime.Now;
var date = new DateTime(now.Year, now.Month, now.Day, int.Parse(time[0]), int.Parse(time[1]), 0);
return Newtonsoft.Json.JsonConvert.SerializeObject(date);
}
public static DateTime ParseTime(string token)
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<DateTime>(token);
}
}