Created
October 2, 2016 17:52
-
-
Save leethomascook/736c998c64294a162a03837081977aa4 to your computer and use it in GitHub Desktop.
Sample DateFormatService
This file contains 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
public class DateFormatService : IDateFormatService | |
{ | |
public virtual string FormatDate(DateTime dateTime, ContentTypeDate format, string language = "en") | |
{ | |
switch (format) | |
{ | |
case ContentTypeDate.PublishedDate: | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
case ContentTypeDate.DateOfBirth: | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
case ContentTypeDate.FullWidthPromoBoxKickOff: | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
case ContentTypeDate.RelatedContent: | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
case ContentTypeDate.UpcomingGamesKickOff: | |
return dateTime.ToDateWithNoYear(); | |
case ContentTypeDate.MatchReport: | |
return dateTime.ToDateWithNoTime(); | |
case ContentTypeDate.Fixture: | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
} | |
return dateTime.ToString(DateFormats.FULL_DATE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment