ToUniversalTime() публичный статический Метод

Converts a DateTime to UTC (with special handling for MinValue and MaxValue).
public static ToUniversalTime ( System.DateTime dateTime ) : System.DateTime
dateTime System.DateTime A DateTime.
Результат System.DateTime
Пример #1
0
        private static int GetTimestampFromDateTime(DateTime timestamp)
        {
            var secondsSinceEpoch = (long)Math.Floor((BsonUtils.ToUniversalTime(timestamp) - BsonConstants.UnixEpoch).TotalSeconds);

            if (secondsSinceEpoch < int.MinValue || secondsSinceEpoch > int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("timestamp");
            }
            return((int)secondsSinceEpoch);
        }
Пример #2
0
 private static int GetTimestampFromDateTime(DateTime timestamp)
 {
     return((int)Math.Floor((BsonUtils.ToUniversalTime(timestamp) - BsonConstants.UnixEpoch).TotalSeconds));
 }