-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelpers.cs
33 lines (30 loc) · 891 Bytes
/
Helpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Globalization;
using ReSchedule.Entities;
namespace ReSchedule;
internal static class Helpers
{
public static (string, List<string>) ParseCommand(string command)
{
var commandName = "";
List<string> args = new();
var split = command.Split(' ');
switch (split.Length)
{
case 1:
commandName = split[0];
break;
case > 1:
(commandName, args) = (split[0], split[1..].ToList());
break;
}
return (commandName, args);
}
public static DateTime ParseTime(string time)
{
return DateTime.ParseExact(time, "H.mm", CultureInfo.InvariantCulture,DateTimeStyles.None);
}
public static string WeekToString(IEnumerable<WeekDay> week)
{
return string.Join('\n', week.Where(w=>w.Pairs.Count!=0));
}
}