本文整理汇总了C#中System.DateTimeRawInfo.GetNumber方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeRawInfo.GetNumber方法的具体用法?C# DateTimeRawInfo.GetNumber怎么用?C# DateTimeRawInfo.GetNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTimeRawInfo
的用法示例。
在下文中一共展示了DateTimeRawInfo.GetNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDayOfYNN
private static bool GetDayOfYNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
int num3;
if ((result.flags & ParseFlags.HaveDate) != 0)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
int number = raw.GetNumber(0);
int month = raw.GetNumber(1);
string shortDatePattern = dtfi.ShortDatePattern;
if (dtfi.CultureId == 0x437)
{
shortDatePattern = dtfi.LongDatePattern;
}
if (GetYearMonthDayOrder(shortDatePattern, dtfi, out num3) && (num3 == 3))
{
if (SetDateYMD(ref result, raw.year, month, number))
{
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else if (SetDateYMD(ref result, raw.year, number, month))
{
result.flags |= ParseFlags.HaveDate;
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例2: GetDateOfNDS
private static bool GetDateOfNDS(ref DateTimeResult result, ref DateTimeRawInfo raw)
{
if (result.Month == -1)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (result.Year != -1)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
result.Year = DateTimeParse.AdjustYear(ref result, raw.GetNumber(0));
result.Day = 1;
return true;
}
示例3: ProcessHebrewTerminalState
internal static bool ProcessHebrewTerminalState(DateTimeParse.DS dps, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
switch (dps)
{
case DateTimeParse.DS.DX_MN:
case DateTimeParse.DS.DX_NM:
{
DateTimeParse.GetDefaultYear(ref result, ref styles);
if (!dtfi.YearMonthAdjustment(ref result.Year, ref raw.month, true))
{
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!DateTimeParse.GetHebrewDayOfNM(ref result, ref raw, dtfi))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.DX_MNN:
{
raw.year = raw.GetNumber(1);
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true))
{
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!DateTimeParse.GetDayOfMNN(ref result, ref raw, dtfi))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.DX_YMN:
{
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true))
{
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!DateTimeParse.GetDayOfYMN(ref result, ref raw, dtfi))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.DX_YM:
{
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true))
{
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!DateTimeParse.GetDayOfYM(ref result, ref raw, dtfi))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.TX_N:
{
if (!DateTimeParse.GetTimeOfN(dtfi, ref result, ref raw))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.TX_NN:
{
if (!DateTimeParse.GetTimeOfNN(dtfi, ref result, ref raw))
{
return false;
}
goto IL_160;
}
case DateTimeParse.DS.TX_NNN:
{
if (!DateTimeParse.GetTimeOfNNN(dtfi, ref result, ref raw))
{
return false;
}
goto IL_160;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
IL_160:
if (dps > DateTimeParse.DS.ERROR)
{
raw.numCount = 0;
}
return true;
}
示例4: GetDayOfYN
private static bool GetDayOfYN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != (ParseFlags)0)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (DateTimeParse.SetDateYMD(ref result, raw.year, raw.GetNumber(0), 1))
{
result.flags |= ParseFlags.HaveDate;
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例5: GetTimeOfNNN
private static bool GetTimeOfNNN(DateTimeFormatInfo dtfi, ref DateTimeResult result, ref DateTimeRawInfo raw)
{
if ((result.flags & ParseFlags.HaveTime) != (ParseFlags)0)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
result.Hour = raw.GetNumber(0);
result.Minute = raw.GetNumber(1);
result.Second = raw.GetNumber(2);
result.flags |= ParseFlags.HaveTime;
return true;
}
示例6: GetHebrewDayOfNM
private static bool GetHebrewDayOfNM(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
int num;
if (!DateTimeParse.GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out num))
{
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.MonthDayPattern);
return false;
}
result.Month = raw.month;
if ((num == 7 || num == 6) && result.calendar.IsValidDay(result.Year, result.Month, raw.GetNumber(0), result.era))
{
result.Day = raw.GetNumber(0);
return true;
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例7: GetDayOfMNN
private static bool GetDayOfMNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != (ParseFlags)0)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
int number = raw.GetNumber(0);
int number2 = raw.GetNumber(1);
int num;
if (!DateTimeParse.GetYearMonthDayOrder(dtfi.ShortDatePattern, dtfi, out num))
{
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.ShortDatePattern);
return false;
}
if (num == 1)
{
int year;
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number2), raw.month, number, result.era))
{
result.SetDate(year, raw.month, number);
result.flags |= ParseFlags.HaveDate;
return true;
}
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number), raw.month, number2, result.era))
{
result.SetDate(year, raw.month, number2);
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else
{
if (num == 0)
{
int year;
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number), raw.month, number2, result.era))
{
result.SetDate(year, raw.month, number2);
result.flags |= ParseFlags.HaveDate;
return true;
}
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number2), raw.month, number, result.era))
{
result.SetDate(year, raw.month, number);
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else
{
if (num == 2)
{
int year;
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number2), raw.month, number, result.era))
{
result.SetDate(year, raw.month, number);
result.flags |= ParseFlags.HaveDate;
return true;
}
if (result.calendar.IsValidDay(year = DateTimeParse.AdjustYear(ref result, number), raw.month, number2, result.era))
{
result.SetDate(year, raw.month, number2);
result.flags |= ParseFlags.HaveDate;
return true;
}
}
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例8: GetDayOfNM
private static Boolean GetDayOfNM(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != 0) {
// Multiple dates in the input string
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
// The interpretation is based on the MonthDayPattern and YearMonthPattern
//
// MonthDayPattern YearMonthPattern Interpretation
// --------------- ---------------- ---------------
// MMMM dd MMMM yyyy Day
// MMMM dd yyyy MMMM Year
// dd MMMM MMMM yyyy Day
// dd MMMM yyyy MMMM Day
//
// In the first and last cases, it could be either or neither, but a day is a better default interpretation
// than a 2 digit year.
int monthDayOrder;
if (!GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out monthDayOrder)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.MonthDayPattern);
return false;
}
if (monthDayOrder == ORDER_MD) {
int yearMonthOrder;
if (!GetYearMonthOrder(dtfi.YearMonthPattern, dtfi, out yearMonthOrder)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.YearMonthPattern);
return false;
}
if (yearMonthOrder == ORDER_YM) {
int year;
if (!TryAdjustYear(ref result, raw.GetNumber(0), out year) || !SetDateYMD(ref result, year, raw.month, 1)) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
return true;
}
}
GetDefaultYear(ref result, ref styles);
if (!SetDateYMD(ref result, result.Year, raw.month, raw.GetNumber(0))) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
return true;
}
示例9: GetDayOfMNN
private static Boolean GetDayOfMNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != 0) {
// Multiple dates in the input string
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
int n1 = raw.GetNumber(0);
int n2 = raw.GetNumber(1);
int order;
if (!GetYearMonthDayOrder(dtfi.ShortDatePattern, dtfi, out order)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.ShortDatePattern);
return false;
}
int year;
if (order == ORDER_MDY)
{
if (TryAdjustYear(ref result, n2, out year) && result.calendar.IsValidDay(year, raw.month, n1, result.era))
{
result.SetDate(year, raw.month, n1); // MDY
result.flags |= ParseFlags.HaveDate;
return true;
}
else if (TryAdjustYear(ref result, n1, out year) && result.calendar.IsValidDay(year, raw.month, n2, result.era))
{
result.SetDate(year, raw.month, n2); // YMD
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else if (order == ORDER_YMD)
{
if (TryAdjustYear(ref result, n1, out year) && result.calendar.IsValidDay(year, raw.month, n2, result.era))
{
result.SetDate(year, raw.month, n2); // YMD
result.flags |= ParseFlags.HaveDate;
return true;
}
else if (TryAdjustYear(ref result, n2, out year) && result.calendar.IsValidDay(year, raw.month, n1, result.era))
{
result.SetDate(year, raw.month, n1); // DMY
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else if (order == ORDER_DMY)
{
if (TryAdjustYear(ref result, n2, out year) && result.calendar.IsValidDay(year, raw.month, n1, result.era))
{
result.SetDate(year, raw.month, n1); // DMY
result.flags |= ParseFlags.HaveDate;
return true;
}
else if (TryAdjustYear(ref result, n1, out year) && result.calendar.IsValidDay(year, raw.month, n2, result.era))
{
result.SetDate(year, raw.month, n2); // YMD
result.flags |= ParseFlags.HaveDate;
return true;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例10: GetDayOfNNN
// Processing teriminal case: DS.DX_NNN
private static Boolean GetDayOfNNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != 0) {
// Multiple dates in the input string
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
int n1 = raw.GetNumber(0);
int n2 = raw.GetNumber(1);;
int n3 = raw.GetNumber(2);
int order;
if (!GetYearMonthDayOrder(dtfi.ShortDatePattern, dtfi, out order)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.ShortDatePattern);
return false;
}
int year;
if (order == ORDER_YMD) {
if (TryAdjustYear(ref result, n1, out year) && SetDateYMD(ref result, year, n2, n3)) // YMD
{
result.flags |= ParseFlags.HaveDate;
return true;
}
} else if (order == ORDER_MDY) {
if (TryAdjustYear(ref result, n3, out year) && SetDateMDY(ref result, n1, n2, year)) // MDY
{
result.flags |= ParseFlags.HaveDate;
return true;
}
} else if (order == ORDER_DMY) {
if (TryAdjustYear(ref result, n3, out year) && SetDateDMY(ref result, n1, n2, year)) // DMY
{
result.flags |= ParseFlags.HaveDate;
return true;
}
} else if (order == ORDER_YDM) {
if (TryAdjustYear(ref result, n1, out year) && SetDateYDM(ref result, year, n2, n3)) // YDM
{
result.flags |= ParseFlags.HaveDate;
return true;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例11: GetHebrewDayOfNM
////////////////////////////////////////////////////////////////////////
// Actions:
// Deal with the terminal state for Hebrew Month/Day pattern
//
////////////////////////////////////////////////////////////////////////
private static Boolean GetHebrewDayOfNM(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
int monthDayOrder;
if (!GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out monthDayOrder)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.MonthDayPattern);
return false;
}
result.Month = raw.month;
if (monthDayOrder == ORDER_DM || monthDayOrder == ORDER_MD)
{
if (result.calendar.IsValidDay(result.Year, result.Month, raw.GetNumber(0), result.era))
{
result.Day = raw.GetNumber(0);
return true;
}
}
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
示例12: GetDateOfNDS
private static Boolean GetDateOfNDS(ref DateTimeResult result, ref DateTimeRawInfo raw)
{
if (result.Month == -1)
{
//Should have a month suffix
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
if (result.Year != -1)
{
// Aleady has a year suffix
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
result.Year = AdjustYear(ref result, raw.GetNumber(0));
result.Day = 1;
return true;
}
示例13: GetTimeOfNN
private static Boolean GetTimeOfNN(DateTimeFormatInfo dtfi, ref DateTimeResult result, ref DateTimeRawInfo raw)
{
if ((result.flags & ParseFlags.HaveTime) != 0)
{
// Multiple times in the input string
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
result.Hour = raw.GetNumber(0);
result.Minute = raw.GetNumber(1);
result.flags |= ParseFlags.HaveTime;
return true;
}
示例14: GetDayOfNN
// Processing teriminal case: DS.DX_NN
private static Boolean GetDayOfNN(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != 0)
{
// Multiple dates in the input string
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
int n1 = raw.GetNumber(0);
int n2 = raw.GetNumber(1);
GetDefaultYear(ref result, ref styles);
int order;
if (!GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out order))
{
result.SetFailure(ParseFailureKind.FormatWithParameter, SR.Format_BadDatePattern, dtfi.MonthDayPattern);
return false;
}
if (order == ORDER_MD)
{
if (SetDateYMD(ref result, result.Year, n1, n2)) // MD
{
result.flags |= ParseFlags.HaveDate;
return true;
}
}
else
{
// ORDER_DM
if (SetDateYMD(ref result, result.Year, n2, n1)) // DM
{
result.flags |= ParseFlags.HaveDate;
return true;
}
}
result.SetFailure(ParseFailureKind.Format, SR.Format_BadDateTime, null);
return false;
}
示例15: ProcessHebrewTerminalState
////////////////////////////////////////////////////////////////////////
//
// Actions:
// This is used by DateTime.Parse().
// Process the terminal state for the Hebrew calendar parsing.
//
////////////////////////////////////////////////////////////////////////
internal static Boolean ProcessHebrewTerminalState(DS dps, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) {
// The following are accepted terminal state for Hebrew date.
switch (dps) {
case DS.DX_MNN:
// Deal with the default long/short date format when the year number is ambigous (i.e. year < 100).
raw.year = raw.GetNumber(1);
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true)) {
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!GetDayOfMNN(ref result, ref raw, dtfi)) {
return false;
}
break;
case DS.DX_YMN:
// Deal with the default long/short date format when the year number is NOT ambigous (i.e. year >= 100).
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true)) {
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!GetDayOfYMN(ref result, ref raw, dtfi)) {
return false;
}
break;
case DS.DX_NM:
case DS.DX_MN:
// Deal with Month/Day pattern.
GetDefaultYear(ref result, ref styles);
if (!dtfi.YearMonthAdjustment(ref result.Year, ref raw.month, true)) {
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!GetHebrewDayOfNM(ref result, ref raw, dtfi)) {
return false;
}
break;
case DS.DX_YM:
// Deal with Year/Month pattern.
if (!dtfi.YearMonthAdjustment(ref raw.year, ref raw.month, true)) {
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!GetDayOfYM(ref result, ref raw, dtfi)) {
return false;
}
break;
case DS.TX_N:
// Deal hour + AM/PM
if (!GetTimeOfN(dtfi, ref result, ref raw)) {
return false;
}
break;
case DS.TX_NN:
if (!GetTimeOfNN(dtfi, ref result, ref raw)) {
return false;
}
break;
case DS.TX_NNN:
if (!GetTimeOfNNN(dtfi, ref result, ref raw)) {
return false;
}
break;
default:
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (dps > DS.ERROR)
{
//
// We have reached a terminal state. Reset the raw num count.
//
raw.numCount = 0;
}
return true;
}