| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- /* 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
- {
- /// <summary>
- /// A static class containing BSON constants.
- /// </summary>
- 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
- /// <summary>
- /// Gets the number of milliseconds since the Unix epoch for DateTime.MaxValue.
- /// </summary>
- public static long DateTimeMaxValueMillisecondsSinceEpoch
- {
- get { return __dateTimeMaxValueMillisecondsSinceEpoch; }
- }
- /// <summary>
- /// Gets the number of milliseconds since the Unix epoch for DateTime.MinValue.
- /// </summary>
- public static long DateTimeMinValueMillisecondsSinceEpoch
- {
- get { return __dateTimeMinValueMillisecondsSinceEpoch; }
- }
- /// <summary>
- /// Gets the Unix Epoch for BSON DateTimes (1970-01-01).
- /// </summary>
- public static DateTime UnixEpoch { get { return __unixEpoch; } }
- }
- }
|