当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeKind类代码示例

本文整理汇总了C#中DateTimeKind的典型用法代码示例。如果您正苦于以下问题:C# DateTimeKind类的具体用法?C# DateTimeKind怎么用?C# DateTimeKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeKind类属于命名空间,在下文中一共展示了DateTimeKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoTest

		private static void DoTest(DateTime dt, DateTimeKind inKind, DateTimeKind outKind)
		{
			Assert.Equal(inKind, dt.Kind);

			using (var documentStore = new EmbeddableDocumentStore { RunInMemory = true })
			{
				documentStore.Initialize();

				using (var session = documentStore.OpenSession())
				{
					session.Store(new Foo { Id = "foos/1", DateTime = dt });
					session.SaveChanges();
				}

				using (var session = documentStore.OpenSession())
				{
					var foo = session.Query<Foo>()
									 .Customize(x => x.WaitForNonStaleResults())
									 .FirstOrDefault(x => x.DateTime == dt);

					WaitForUserToContinueTheTest(documentStore);

					Assert.Equal(dt, foo.DateTime);
					Assert.Equal(outKind, foo.DateTime.Kind);
				}
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:27,代码来源:DateTime_QueryDynamicTests.cs

示例2: GetDateInUserTimeZone

 public static DateTime GetDateInUserTimeZone(DateTime sourceDate, DateTimeKind sourceDateTimeKind, User user)
 {
     sourceDate = DateTime.SpecifyKind(sourceDate, sourceDateTimeKind);
     //get the timezone of mentioned user
     var userTimezoneId = user.GetPropertyValueAs<string>(PropertyNames.DefaultTimeZoneId);
     if (string.IsNullOrEmpty(userTimezoneId))
     {
         //get default timezone
         var generalSettings = mobSocialEngine.ActiveEngine.Resolve<GeneralSettings>();
         userTimezoneId = generalSettings.DefaultTimeZoneId;
     }
     //let's find the timezone
     TimeZoneInfo timeZoneInfo;
     try
     {
         timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(userTimezoneId);
     }
     catch
     {
         //in case of error let's default to local timezone
         timeZoneInfo = TimeZoneInfo.Local;
     }
     //get the timezone
     return GetDateInTimeZone(sourceDate, timeZoneInfo);
 }
开发者ID:mobsoftware,项目名称:mobsocial,代码行数:25,代码来源:DatetimeHelper.cs

示例3: DateParser

        public DateParser(string format, DateTimeKind kind)
        {
            switch (kind)
            {
                case DateTimeKind.Local:
                    _style = DateTimeStyles.AssumeLocal;
                    break;

                case DateTimeKind.Utc:
                    _style = DateTimeStyles.AssumeUniversal;
                    break;

                default:
                    throw new ArgumentOutOfRangeException("kind");
            }

            switch (format)
            {
                case "ABSOLUTE":
                    break;

                case "ISO8601":
                    break;

                case "DATE":
                    break;
            }
        }
开发者ID:Kittyfisto,项目名称:Tailviewer,代码行数:28,代码来源:DateParser.cs

示例4: GetMinValue

        /// <summary>
        /// Gets the Minimum value for a DateTime specifying kind.
        /// </summary>
        /// <param name="kind">DateTimeKind to use.</param>
        /// <returns>DateTime of specified kind.</returns>
        public static DateTime GetMinValue(DateTimeKind kind)
        {
            if (kind == DateTimeKind.Unspecified)
                return new DateTime(DateTime.MinValue.Ticks, DateTimeKind.Utc);

            return new DateTime(DateTime.MinValue.Ticks, kind);
        }
开发者ID:vebin,项目名称:azure-activedirectory-identitymodel-extensions-for-dotnet,代码行数:12,代码来源:DateTimeUtil.cs

示例5: Compare

        /// <summary>
        /// 現在のインスタンスと比較します。
        /// </summary>
        /// <param name="self">自分自身</param>
        /// <param name="value">比較する値</param>
        /// <param name="compareKind">比較する時間の種別</param>
        /// <returns>比較結果(true:一致, false:不一致)</returns>
        public static bool Compare(this DateTime self, DateTime value, DateTimeKind compareKind)
        {
            var ts = self - value;
            double total = 0D;
            double sub = 1.0D;

            switch (compareKind)
            {
                case DateTimeKind.Year:
                    total = self.Year - value.Year;
                    break;
                case DateTimeKind.Month:
                    sub = 30.0D;
                    total = ts.TotalDays;
                    break;
                case DateTimeKind.Day:
                    total = ts.TotalDays;
                    break;
                case DateTimeKind.Hour:
                    total = ts.TotalHours;
                    break;
                case DateTimeKind.Minute:
                    total = ts.TotalMinutes;
                    break;
                case DateTimeKind.Second:
                    total = ts.TotalSeconds;
                    break;
                case DateTimeKind.Milliseconds:
                    total = ts.TotalMilliseconds;
                    break;
            }

            return Math.Abs(total) < sub;
        }
开发者ID:Iyemon-018,项目名称:Dev,代码行数:41,代码来源:DateTimeExtensions.cs

示例6: SetPosition

 public void SetPosition(DateTime when, DateTimeKind whenKind, double latitudeDegrees, double longitudeDegrees)
 {
   IntPtr pSun = NonConstPointer();
   UnsafeNativeMethods.Rdk_Sun_SetLatitudeLongitude(pSun, latitudeDegrees, longitudeDegrees);
   bool local = whenKind != DateTimeKind.Utc;
   UnsafeNativeMethods.Rdk_Sun_SetDateTime(pSun, local, when.Year, when.Month, when.Day, when.Hour, when.Minute, when.Second);
 }
开发者ID:austinlaw,项目名称:rhinocommon,代码行数:7,代码来源:sun.cs

示例7: DateTimeSerializationOptions

 /// <summary>
 /// Initializes a new instance of the DateTimeSerializationOptions class.
 /// </summary>
 /// <param name="kind">The DateTimeKind (Local, Unspecified or Utc).</param>
 /// <param name="representation">The external representation.</param>
 public DateTimeSerializationOptions(
     DateTimeKind kind,
     BsonType representation
 ) {
     this.kind = kind;
     this.representation = representation;
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:12,代码来源:DateTimeSerializationOptions.cs

示例8: DateTimeRule

 /// <summary>
 /// Initializes a new instance of the <see cref="UserDataRule" /> class.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="kind">The kind.</param>
 /// <param name="appliesWhen">The rule can be applied to insert, update, and/or soft delete operations.</param>
 /// <exception cref="ArgumentOutOfRangeException">appliesWhen;appliesWhen may only be a combination of Insert, Update, or Delete</exception>
 /// <remarks>
 /// This will have no effect on hard deletes.
 /// </remarks>
 public DateTimeRule(string columnName, DateTimeKind kind, OperationTypes appliesWhen) : base(columnName, appliesWhen)
 {
     if (appliesWhen.HasFlag(OperationTypes.Select))
         throw new ArgumentOutOfRangeException("appliesWhen", appliesWhen, "appliesWhen may only be a combination of Insert, Update, or Delete");
     if (kind == DateTimeKind.Unspecified)
         throw new ArgumentOutOfRangeException("kind");
     Kind = kind;
 }
开发者ID:docevaad,项目名称:Chain,代码行数:18,代码来源:DateTimeRule.cs

示例9: LoadJPEG

 public static SharpMapillaryInfo LoadJPEG(this SharpMapillaryInfo           MapillaryInfo,
                                           String                            JPEGFile,
                                           DateTimeKind                      DateTimeType         = DateTimeKind.Utc,
                                           Int32?                            TimeOffset           = null,
                                           Func<String, DateTime, DateTime>  OnDupliateTimestamp  = null)
 {
     return LoadJPEG(JPEGFile, ref MapillaryInfo, DateTimeType, TimeOffset, OnDupliateTimestamp);
 }
开发者ID:GraphDefined,项目名称:SharpMapillary,代码行数:8,代码来源:LoadJPGs.cs

示例10: BsonReader

 /// <summary>
 /// Initializes a new instance of the <see cref="BsonReader"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="readRootValueAsArray">if set to <c>true</c> the root object will be read as a JSON array.</param>
 /// <param name="dateTimeKindHandling">The <see cref="DateTimeKind" /> used when reading <see cref="DateTime"/> values from BSON.</param>
 public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling)
 {
     ValidationUtils.ArgumentNotNull(stream, "stream");
     _reader = new BinaryReader(stream);
     _stack = new List<ContainerContext>();
     _readRootValueAsArray = readRootValueAsArray;
     _dateTimeKindHandling = dateTimeKindHandling;
 }
开发者ID:ThePiachu,项目名称:BitNet,代码行数:14,代码来源:BsonReader.cs

示例11: DateTimeDataType

 public DateTimeDataType(int id, string name, string alias, DataType basic, DataType parent, bool editable,
     DateTimeKind part, DateTime minValue, DateTime maxValue, bool nullable)
     : base(id, name, alias, basic, parent, editable, nullable)
 {
     this.part = part;
     this.minValue = minValue;
     this.maxValue = maxValue;
 }
开发者ID:jihadbird,项目名称:firespider,代码行数:8,代码来源:DateTimeDataType.cs

示例12: FromSortableIntDateTime

        /// <summary>
        ///     Returns DateTime created from an integer in the YYYYMMDD, YYYYMMDDHHmmss, or YYYYMMDDHHmmssFFF format.
        /// </summary>
        /// <param name="sortableDateTime"></param>
        /// <param name="dtKind"></param>
        /// <returns></returns>
        public static DateTime? FromSortableIntDateTime(this string sortableDateTime, DateTimeKind dtKind = DateTimeKind.Unspecified)
        {
            long? sortableVal = sortableDateTime.ParseLong();
            if(sortableVal == null)
                return null;

            return sortableVal.Value.FromSortableIntDateTime(dtKind);
        }
开发者ID:vgribok,项目名称:Aspectacular,代码行数:14,代码来源:DateTimeExtensions.cs

示例13: GetDateTime

        /// <summary>
        /// Obtient une date dans le kind spécifié en fonction des paramètres spécifiés
        /// </summary>
        /// <param name="rule"><see cref="RuleDate"/> décrivant la date</param>
        /// <param name="year">Année de la date</param>
        /// <param name="gmtOffset">Offset gmt dans lequel est exprimé la date</param>
        /// <param name="stdOffset">Offset standard dans lequel est exprimé la date</param>
        /// <param name="dateTimeKind"><see cref="DateTimeKind"/> dans lequel exprimer la date</param>
        /// <returns><see cref="DateTime"/> du kind spécifié correspondant aux paramètres spécifiés</returns>
        public static DateTime GetDateTime(RuleDate rule, int year, TimeSpan gmtOffset, TimeSpan stdOffset, DateTimeKind dateTimeKind)
        {
            if (dateTimeKind == DateTimeKind.Unspecified) throw new ArgumentException("Unspecified date time kind", "dateTimeKind");

            if (dateTimeKind == DateTimeKind.Local)
                return GetWallClockTime(rule, year, gmtOffset, stdOffset);
            return GetUTCTime(rule, year, gmtOffset, stdOffset);
        }
开发者ID:LZorglub,项目名称:TimeZone,代码行数:17,代码来源:TzUtilities.cs

示例14: __DateTime

        public __DateTime()
        {
            this.Kind = DateTimeKind.Local;
            // fix for default(DateTime).ToString
            // X:\jsc.svn\examples\javascript\Test\TestDateTime\TestDateTime\Program.cs
            this.InternalValue = new IDate();

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:DateTime.cs

示例15: GetCurrentTime

 public DateTime GetCurrentTime(DateTimeKind dateTimeKind)
 {
     switch (dateTimeKind)
     {
         case DateTimeKind.Local: return DateTime.Now.ToLocalTime();
         case DateTimeKind.Utc: return DateTime.Now.ToUniversalTime();
         default: return DateTime.Now;
     }
 }
开发者ID:ittray,项目名称:LocalDemo,代码行数:9,代码来源:DefaultTimeProvider.cs


注:本文中的DateTimeKind类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。