public static string FormatDate(DateTime date, DateFormattingOptions options) { string formatted; switch (options.DateFormat) { default: formatted = AgoFormat(ref date); break; case DateFormat.LongDateFormat: formatted = date.ToString(LocalizationService.Current.GetString("/Common/DateTime/DateFormat")); break; case DateFormat.ShortDateFormat: formatted = date.ToString(LocalizationService.Current.GetString("/Common/DateTime/ShortDateFormat")); break; case DateFormat.FullDateTimeFormat: formatted = date.ToString(LocalizationService.Current.GetString("/Common/DateTime/FullDateTimeFormat")); break; } if (options.LowerCaseFirstLetter) formatted = FormatText(formatted, new TextFormattingOptions() { LowerCaseFirstLetter = true }); return formatted; }
public static string ToFormatted(this DateTime date, DateFormattingOptions options) { return FormattingUtilities.FormatDate(date, options); }