static string FormatDateTimeTimeZone( Microsoft.Graph.DateTimeTimeZone value, string dateTimeFormat) { // Parse the date/time string from Graph into a DateTime var dateTime = DateTime.Parse(value.DateTime); return(dateTime.ToString(dateTimeFormat)); }
static string FormatDateTimeTimeZone(Microsoft.Graph.DateTimeTimeZone value) { // Get the timezone specified in the Graph value var timeZone = TimeZoneInfo.FindSystemTimeZoneById(value.TimeZone); // Parse the date/time string from Graph into a DateTime var dateTime = DateTime.Parse(value.DateTime); // Create ad DateTimeOffset in the specific timezone indicated by Graph var dateTimeWithTZ = new DateTimeOffset(dateTime, timeZone.BaseUtcOffset) .ToLocalTime(); return(dateTimeWithTZ.ToString("g")); }
static string FormatDateTimeTimeZone( Microsoft.Graph.DateTimeTimeZone value, string dateTimeFormat) { // Parse the date/time string from Graph into a DateTime var dateTime = DateTime.Parse(value.DateTime); if (dateTimeFormat != " ") { return(dateTime.ToString(dateTimeFormat)); } else { return(dateTime.ToString(DateTime.Now.ToString("MM/dd/yyyy"))); } }