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


C# DateTimeKind.ToString方法代码示例

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


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

示例1: VerifyDateTimeHelper

    private bool VerifyDateTimeHelper(int desiredYear, 
        int desiredMonth, 
        int desiredDay, 
        int desiredHour, 
        int desiredMinute, 
        int desiredSecond,
        DateTimeKind desiredKind)
    {
        bool retVal = true;

        DateTime value = new DateTime(desiredYear, desiredMonth, desiredDay, 
            desiredHour, desiredMinute, desiredSecond, desiredKind);

        m_ErrorNo++;
        if ((desiredYear != value.Year) || 
            (desiredMonth != value.Month) || 
            (desiredDay != value.Day) ||
            (desiredHour != value.Hour) || 
            (desiredMinute != value.Minute) || 
            (desiredSecond != value.Second) ||
            (desiredKind != value.Kind))
        {
            TestLibrary.TestFramework.LogError(m_ErrorNo.ToString(), "Calling ctor constructors a wrong DateTime instance by using valid value");
            TestLibrary.TestFramework.LogInformation("[LOCAL VARIABLES] desiredYear = " + desiredYear.ToString() +
                                                                                             ", desiredMonth = " + desiredMonth.ToString() +
                                                                                             ", desiredDay = " + desiredDay.ToString() +
                                                                                             ", desiredHour = " + desiredHour.ToString() +
                                                                                             ", desiredMinute = " + desiredMinute.ToString() +
                                                                                             ", desiredSecond = " + desiredSecond.ToString() +
                                                                                             ", desiredKind = " + desiredKind.ToString() +
                                                                                             ", actualYear = " + value.Year.ToString() +
                                                                                             ", actualMonth = " + value.Month.ToString() +
                                                                                             ", actualDay = " + value.Day.ToString() +
                                                                                             ", actualHour = " + value.Hour.ToString() +
                                                                                             ", actualMinute = " + value.Minute.ToString() +
                                                                                             ", actualSecond = " + value.Second.ToString() +
                                                                                             ", actualKind = " + value.Kind.ToString());
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:42,代码来源:datetimector4.cs

示例2: ReadTimeSpanTicks

 private static long ReadTimeSpanTicks(ProtoReader source, out DateTimeKind kind) {
     kind = DateTimeKind.Unspecified;
     switch (source.WireType)
     {
         case WireType.String:
         case WireType.StartGroup:
             SubItemToken token = ProtoReader.StartSubItem(source);
             int fieldNumber;
             TimeSpanScale scale = TimeSpanScale.Days;
             long value = 0;
             while ((fieldNumber = source.ReadFieldHeader()) > 0)
             {
                 switch (fieldNumber)
                 {
                     case FieldTimeSpanScale:
                         scale = (TimeSpanScale)source.ReadInt32();
                         break;
                     case FieldTimeSpanValue:
                         source.Assert(WireType.SignedVariant);
                         value = source.ReadInt64();
                         break;
                     case FieldTimeSpanKind:
                         kind = (DateTimeKind)source.ReadInt32();
                         switch(kind)
                         {
                             case DateTimeKind.Unspecified:
                             case DateTimeKind.Utc:
                             case DateTimeKind.Local:
                                 break; // fine
                             default:
                                 throw new ProtoException("Invalid date/time kind: " + kind.ToString());
                         }
                         break;
                     default:
                         source.SkipField();
                         break;
                 }
             }
             ProtoReader.EndSubItem(token, source);
             switch (scale)
             {
                 case TimeSpanScale.Days:
                     return value * TimeSpan.TicksPerDay;
                 case TimeSpanScale.Hours:
                     return value * TimeSpan.TicksPerHour;
                 case TimeSpanScale.Minutes:
                     return value * TimeSpan.TicksPerMinute;
                 case TimeSpanScale.Seconds:
                     return value * TimeSpan.TicksPerSecond;
                 case TimeSpanScale.Milliseconds:
                     return value * TimeSpan.TicksPerMillisecond;
                 case TimeSpanScale.Ticks:
                     return value;
                 case TimeSpanScale.MinMax:
                     switch (value)
                     {
                         case 1: return long.MaxValue;
                         case -1: return long.MinValue;
                         default: throw new ProtoException("Unknown min/max value: " + value.ToString());
                     }
                 default:
                     throw new ProtoException("Unknown timescale: " + scale.ToString());
             }
         case WireType.Fixed64:
             return source.ReadInt64();
         default:
             throw new ProtoException("Unexpected wire-type: " + source.WireType.ToString());
     }
 }
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:69,代码来源:BclHelpers.cs

示例3: DateTimeKindAttribute

 public DateTimeKindAttribute(DateTimeKind kind)
     : this(kind, "Invalid DateTimeKind, must be "+kind.ToString())
 {
 }
开发者ID:gosuto,项目名称:tfs2.com,代码行数:4,代码来源:DateTimeKindAttribute.cs


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