/// <summary> /// Returns a DateTimeOffset with an offset of zero (UTC) for the value passed in, if it cannot be parsed a null is returned. /// </summary> /// <param name="val"></param> /// <returns></returns> internal static DateTimeOffset?FromExamineDateTime(string val) { long output; if (long.TryParse(val, out output)) { return(new DateTimeOffset(LuceneIndexer.DateTimeFromTicks(output), new TimeSpan(0, 0, 0))); } return(null); }
/// <summary> /// Returns a DateTimeOffset object from the field in the search result specified or null if conversion couldn't be done or the /// required fields could not be found. /// </summary> /// <param name="r"></param> /// <param name="fieldName"></param> /// <returns></returns> internal static DateTimeOffset?FromExamineDateTime(IDictionary <string, string> r, string fieldName) { long output; var dateTime = r.GetValue(fieldName, "notfound"); if (long.TryParse(dateTime, out output)) { if (!r.ContainsKey(fieldName + FixedIndexedFields.DateTimeOffsetSuffix)) { return(null); } int offset; if (!Int32.TryParse(r[fieldName + FixedIndexedFields.DateTimeOffsetSuffix], out offset)) { return(null); } return(new DateTimeOffset(LuceneIndexer.DateTimeFromTicks(output), new TimeSpan(0, offset, 0))); } return(null); }