Retrospection.PersonalAnalyticsHttp.GetVisualizationDateFromUrlParameters C# (CSharp) Method

GetVisualizationDateFromUrlParameters() public static method

Parses the request parameter (for "date") as a DateTime or returns a fallback value if there is no or if it fails.
public static GetVisualizationDateFromUrlParameters ( HttpReqResp req ) : DateTimeOffset
req HttpReqResp
return DateTimeOffset
        public static DateTimeOffset GetVisualizationDateFromUrlParameters(HttpReqResp req)
        {
            var fallbackDate = DateTimeOffset.Now;
            try
            {
                var dateParam = req["date"];
                if (dateParam != null)
                {
                    return DateTimeOffset.Parse(dateParam, CultureInfo.InvariantCulture);
                }
            }
            catch { }

            return fallbackDate;
        }