コード例 #1
0
 /// <summary>Converts a DateTime (in DotNet) or Date (in Java) to a
 /// CBOR object in a manner specified by this converter's conversion
 /// type.</summary>
 /// <param name='obj'>The parameter <paramref name='obj'/> is a
 /// DateTime object.</param>
 /// <returns>A CBOR object encoding the date/time in the DateTime or
 /// Date according to the conversion type used to create this date
 /// converter.</returns>
 /// <exception cref='PeterO.Cbor2.CBORException'>An error occurred in
 /// conversion.</exception>
 public CBORObject ToCBORObject(DateTime obj)
 {
     try {
         var lesserFields = new int[7];
         var outYear      = new EInteger[1];
         PropertyMap.BreakDownDateTime(obj, outYear, lesserFields);
         return(this.DateTimeFieldsToCBORObject(outYear[0], lesserFields));
     } catch (ArgumentException ex) {
         throw new CBORException(ex.Message, ex);
     }
 }
コード例 #2
0
 private static string DateTimeToString(DateTime bi)
 {
     try {
         var lesserFields = new int[7];
         var outYear      = new EInteger[1];
         PropertyMap.BreakDownDateTime(bi, outYear, lesserFields);
         return(CBORUtilities.ToAtomDateTimeString(outYear[0], lesserFields));
     } catch (ArgumentException ex) {
         throw new CBORException(ex.Message, ex);
     }
 }