Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created October 25, 2013 11:32
Show Gist options
  • Save csharpforevermore/7153258 to your computer and use it in GitHub Desktop.
Save csharpforevermore/7153258 to your computer and use it in GitHub Desktop.
Returns the text that comes after a digit in a date (e.g. 1 = 1st, 15 = 15th, 23 = 23rd, etc)
public static string GetDaySuffix(int day)
{
switch (day)
{
case 1:
case 21:
case 31:
return "st";
case 2:
case 22:
return "nd";
case 3:
case 23:
return "rd";
default:
return "th";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment