Esempio n. 1
0
 public static string ConvertTimeOnly(System.DateTime dt, TimeStampPrecision precision)
 {
     if (precision == TimeStampPrecision.Nanosecond)
     {
         return(string.Format(TIME_ONLY_FORMAT_WITH_NANOSECONDS, dt, dt.SubsecondAsNanoseconds()));
     }
     else
     {
         var format = TIME_ONLY_PRECISION_TO_FORMAT[precision];
         return(string.Format(format, dt));
     }
 }
 /// <summary>
 /// Convert string to DateTime
 /// </summary>
 /// <exception cref="FieldConvertError"/>
 public static System.DateTime ConvertToDateTime(string str, TimeStampPrecision precision)
 {
     try
     {
         if (precision == TimeStampPrecision.Nanosecond)
         {
             return(DateTimeFromNanoString(str));
         }
         else
         {
             return(System.DateTime.ParseExact(str, DATE_TIME_FORMATS, DATE_TIME_CULTURE_INFO, DATE_TIME_STYLES));
         }
     }
     catch (System.Exception e)
     {
         throw new FieldConvertError("Could not convert string (" + str + ") to DateTime: " + e.Message, e);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Convert string to DateTime
 /// </summary>
 /// <exception cref="FieldConvertError"/>
 public static System.DateTime ConvertToDateTime(string str, TimeStampPrecision precision)
 {
     try
     {
         //Avoid NanoString Path parsing if not possible from string length
         if (str.Length > DATE_TIME_MAXLENGTH_WITHOUT_NANOSECONDS)
         {
             return(DateTimeFromNanoString(str));
         }
         else
         {
             return(System.DateTime.ParseExact(str, DATE_TIME_FORMATS, DATE_TIME_CULTURE_INFO, DATE_TIME_STYLES));
         }
     }
     catch (System.Exception e)
     {
         throw new FieldConvertError("Could not convert string (" + str + ") to DateTime: " + e.Message, e);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Check if string is TimeOnly and, if yes, convert to DateTime.  Optional time stamp precision up to
 /// </summary>
 /// <param name="str"></param>
 /// /// <param name="precision"></param>
 /// <returns></returns>
 /// <exception cref="FieldConvertError"/>
 public static System.DateTime ConvertToTimeOnly(string str, TimeStampPrecision precision)
 {
     try
     {
         System.DateTime d;
         if (precision == TimeStampPrecision.Nanosecond)
         {
             d = TimeOnlyFromNanoString(str);
         }
         else
         {
             d = System.DateTime.ParseExact(str, TIME_ONLY_FORMATS, DATE_TIME_CULTURE_INFO, DATE_TIME_STYLES);
         }
         return(new System.DateTime(1980, 1, 1) + d.TimeOfDay);
     }
     catch (System.Exception e)
     {
         throw new FieldConvertError("Could not convert string (" + str + ") to TimeOnly: " + e.Message, e);
     }
 }
Esempio n. 5
0
        public WriteOptions SetTimeStampPrecision(TimeStampPrecision value)
        {
            TimeStampPrecision = value;

            return this;
        }
Esempio n. 6
0
        public static string ConvertTimeOnly(System.DateTime dt, TimeStampPrecision precision)
        {
            var format = TIME_ONLY_PRECISION_TO_FORMAT[precision];

            return(string.Format(format, dt));
        }
Esempio n. 7
0
 public TimeOnlyField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
     : base(tag, dt, timeFormatPrecision)
 {
 }
Esempio n. 8
0
 public DateTimeField(int tag, DateTime dt, TimeStampPrecision timeFormatPrecision)
     : base(tag, dt)
 {
     timePrecision = timeFormatPrecision;
 }