예제 #1
0
        private static TimeSpan?ToTimeSpan(object value, TypeInspector type)
        {
            if (type.Is(TypeFlags.Integer64))
            {
                return(new TimeSpan(System.Convert.ToInt64(value)));
            }

            if (type.Is(TypeFlags.Numeric))
            {
                return(TimeSpan.FromSeconds(System.Convert.ToDouble(value)));
            }

            return(null);
        }
예제 #2
0
        private static DateTime?ToDateTime(object value, TypeInspector type)
        {
            if (type.Is(TypeFlags.Integer64)) // Assume .NET ticks
            {
                return(new DateTime(System.Convert.ToInt64(value)));
            }

            if (type.Is(TypeFlags.Integer32)) // Assume Unix seconds since 1970-01-01
            {
                return(new DateTime(1970, 1, 1).AddSeconds(System.Convert.ToInt32(value)));
            }

            if (type.Is(TypeFlags.FloatingPoint))
            {
                return(JulianToDateTime(System.Convert.ToDouble(value)));
            }

            return(null);
        }