Created
October 27, 2017 09:38
-
-
Save ps-team/17c224c706dd6c81196771cc66d80058 to your computer and use it in GitHub Desktop.
Gets suffix for current day (st, nd, rd or th)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
int lastUpdatedOnDay = CurrentNode.Data.DateModified.Day; | |
string lastUpdatedOn = lastUpdatedOnDay + GetDaySuffix(lastUpdatedOnDay) + CurrentNode.Data.DateModified.ToString(" MMMM yyyy"); | |
} | |
<span>Last updated on @lastUpdatedOn</span> | |
@functions { | |
//Gets suffix for current day (st, nd, rd or th) | |
string GetDaySuffix(int day) | |
{ | |
if (day == 1 || day == 21 || day == 31) | |
{ | |
return "st"; | |
} | |
else if (day == 2 || day == 22) | |
{ | |
return "nd"; | |
} | |
else if (day == 3 || day == 23) | |
{ | |
return "rd"; | |
} | |
else | |
{ | |
return "th"; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
Dim lastUpdatedOnDay As Int = CurrentNode.Data.DateModified.Day | |
Dim lastUpdatedOn As String = lastUpdatedOnDay + GetDaySuffix(lastUpdatedOnDay) + CurrentNode.Data.DateModified.ToString(" MMMM yyyy") | |
} | |
<span>Last updated on @lastUpdatedOn</span> | |
@Functions | |
Function GetDaySuffix(day As Integer) As String | |
Select Case day | |
Case 1, 21, 31 | |
Return "st" | |
Case 2, 22 | |
Return "nd" | |
Case 3, 23 | |
Return "rd" | |
Case Else | |
Return "th" | |
End Select | |
End Function | |
End Functions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment