Skip to content

Instantly share code, notes, and snippets.

@chriskooken
Created May 11, 2010 14:39
Show Gist options
  • Save chriskooken/397386 to your computer and use it in GitHub Desktop.
Save chriskooken/397386 to your computer and use it in GitHub Desktop.
Transform("NOTHING", () =>
{
return null as string;
});
Transform(@"(TODAY|TOMORROW|YESTERDAY) at ([0-9]{2})([0-9]{2})\Z", (string day, string time1, string time2) =>
{
var datePart = string.Empty;
switch (day)
{
case "TODAY":
datePart = DateTime.UtcNow.Date.ToShortDateString();
break;
case "TOMORROW":
datePart = DateTime.UtcNow.Date.AddDays(1).ToShortDateString();
break;
case "YESTERDAY":
datePart = DateTime.UtcNow.Date.AddDays(-1).ToShortDateString();
break;
}
var timePart = time1 + ":" + time2;
var returnVal = DateTime.SpecifyKind(DateTime.Parse(string.Format("{0} {1}:00", datePart, timePart)), DateTimeKind.Utc);
return returnVal;
});
Transform(@"(TODAY|TOMORROW|YESTERDAY)\Z", day =>
{
switch (day)
{
case "TODAY":
return DateTime.UtcNow.Date;
case "TOMORROW":
return DateTime.UtcNow.Date.AddDays(1);
default:
return DateTime.UtcNow.Date.AddDays(-1);
}
});
Patients();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment