Skip to content

Commit

Permalink
Added time parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Mar 6, 2024
1 parent 56ab7e5 commit 835801d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Tikhole.Engine/Syncer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,23 @@ await Task.Run(() => {
}
if (word.StartsWith("=timeout="))
{
CTV.Timeout = DateTime.Now.AddDays(1); //THIS NEEDS REPLACED WITH PARSED DATETIME.
string sNumber = string.Empty;
string time = word.Replace("=timeout=", "");
DateTime timeout = DateTime.Now;
foreach (char character in time)
{
if ("1234567890".Contains(character)) sNumber += character;
if ("wdhms".Contains(character) && uint.TryParse(sNumber, out uint number))
{
if (character == 'w') timeout = timeout.AddDays(number * 7);
if (character == 'd') timeout = timeout.AddDays(number);
if (character == 'h') timeout = timeout.AddHours(number);
if (character == 'm') timeout = timeout.AddMinutes(number);
if (character == 's') timeout = timeout.AddSeconds(number);
sNumber = string.Empty;
}
}
CTV.Timeout = timeout;
}
if (word == "")
{
Expand All @@ -82,7 +98,6 @@ await Task.Run(() => {
skip = false;
continue;
}
CTV.Timeout = DateTime.Now.AddDays(1); //THIS NEEDS REMOVED.
if (CTV.Timeout == new DateTime()) continue;
stagedTrackList.Add(CTK, CTV);
}
Expand Down

0 comments on commit 835801d

Please sign in to comment.