Permalink
Browse files

Add more terms to date time parser

  • Loading branch information...
1 parent 21358c3 commit e27e5937d356268c79816877cc5053a5b38ac923 @abdullin abdullin committed Feb 28, 2013
Showing with 16 additions and 3 deletions.
  1. +16 −3 Source/Gtd.Console/Commands/ArchiveThoughtCommand.cs
View
19 Source/Gtd.Console/Commands/ArchiveThoughtCommand.cs
@@ -86,15 +86,28 @@ public static bool TryParseDate(string value, out DateTime span)
if (string.IsNullOrWhiteSpace(value))
return false;
- value = value.Trim();
+ value = value.Trim().ToLowerInvariant();
+
+ switch (value)
+ {
+ case "now":
+ span = DateTime.UtcNow;
+ return true;
+ case "today":
+ span = DateTime.UtcNow.Date.AddHours(8);
+ return true;
+ case "tomorrow":
+ span = DateTime.UtcNow.Date.AddHours(8).AddDays(1);
+ return true;
+ }
try
{
if (TryRepresent(value, new[] {"w", "wk", "week"}, (diff, source) => source.AddDays(7 * diff) , out span))
return true;
- if (TryRepresent(value, new string[] {"d", "day", "days"},(diff, source) => source.AddDays(diff), out span))
+ if (TryRepresent(value, new[] {"d", "day", "days"},(diff, source) => source.AddDays(diff), out span))
return true;
- if (TryRepresent(value, new string[] {"m", "mth", "month"}, (diff, source) => source.AddMonths((int)diff),out span)) ;
+ if (TryRepresent(value, new[] {"m", "mth", "month"}, (diff, source) => source.AddMonths((int)diff),out span)) ;

0 comments on commit e27e593

Please sign in to comment.