/// <summary>Converts a CBOR object to a DateTime (in DotNet) or a Date /// (in Java).</summary> /// <param name='obj'>A CBOR object that specifies a date/time /// according to the conversion type used to create this date /// converter.</param> /// <returns>A DateTime or Date that encodes the date/time specified in /// the CBOR object.</returns> /// <exception cref='ArgumentNullException'>The parameter <paramref /// name='obj'/> is null.</exception> /// <exception cref='PeterO.Cbor2.CBORException'>The format of the CBOR /// object is not supported, or another error occurred in /// conversion.</exception> public DateTime FromCBORObject(CBORObject obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } var lesserFields = new int[7]; var outYear = new EInteger[1]; string str = this.TryGetDateTimeFieldsInternal( obj, outYear, lesserFields); if (str == null) { return(PropertyMap.BuildUpDateTime(outYear[0], lesserFields)); } throw new CBORException(str); }