25 lines
763 B
C#
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);
|
|
}
|
|
} |