/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace MongoDB.Bson
{
///
/// A static class containing BSON constants.
///
public static class BsonConstants
{
// private static fields
private static readonly long __dateTimeMaxValueMillisecondsSinceEpoch;
private static readonly long __dateTimeMinValueMillisecondsSinceEpoch;
private static readonly DateTime __unixEpoch;
// static constructor
static BsonConstants()
{
// unixEpoch has to be initialized first
__unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
__dateTimeMaxValueMillisecondsSinceEpoch = (DateTime.MaxValue - __unixEpoch).Ticks / 10000;
__dateTimeMinValueMillisecondsSinceEpoch = (DateTime.MinValue - __unixEpoch).Ticks / 10000;
}
// public static properties
///
/// Gets the number of milliseconds since the Unix epoch for DateTime.MaxValue.
///
public static long DateTimeMaxValueMillisecondsSinceEpoch
{
get { return __dateTimeMaxValueMillisecondsSinceEpoch; }
}
///
/// Gets the number of milliseconds since the Unix epoch for DateTime.MinValue.
///
public static long DateTimeMinValueMillisecondsSinceEpoch
{
get { return __dateTimeMinValueMillisecondsSinceEpoch; }
}
///
/// Gets the Unix Epoch for BSON DateTimes (1970-01-01).
///
public static DateTime UnixEpoch { get { return __unixEpoch; } }
}
}