public static string FormatEventDate(XrmServiceContext context, Campaign campaign, DateTime?value) { if (value == null) { return(string.Empty); } var formatter = DateTimeFormatter.ForEvent(context, campaign); var output = new StringBuilder(HtmlEncode(formatter.Format(value.Value))); if (!string.IsNullOrEmpty(formatter.TimeZoneLabel)) { output.AppendFormat(" ({0})", HtmlEncode(formatter.TimeZoneLabel)); } return(output.ToString()); }
public static string FormatEventDateRange(XrmServiceContext context, Campaign campaign) { var formatter = DateTimeFormatter.ForEvent(context, campaign); if (campaign.MSA_StartDateTime == null) { return(string.Empty); } var output = new StringBuilder(HtmlEncode(formatter.Format(campaign.MSA_StartDateTime.Value))); if (campaign.MSA_EndDateTime.HasValue) { output.AppendFormat(" – {0}", HtmlEncode(formatter.Format(campaign.MSA_EndDateTime.Value))); } if (!string.IsNullOrEmpty(formatter.TimeZoneLabel)) { output.AppendFormat(" ({0})", HtmlEncode(formatter.TimeZoneLabel)); } return(output.ToString()); }