Skip to content

Instantly share code, notes, and snippets.

@leethomascook
Created October 2, 2016 17:52
Show Gist options
  • Save leethomascook/736c998c64294a162a03837081977aa4 to your computer and use it in GitHub Desktop.
Save leethomascook/736c998c64294a162a03837081977aa4 to your computer and use it in GitHub Desktop.
Sample DateFormatService
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