本文整理汇总了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;
}
示例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());
}
}
示例3: DateTimeKindAttribute
public DateTimeKindAttribute(DateTimeKind kind)
: this(kind, "Invalid DateTimeKind, must be "+kind.ToString())
{
}