本文整理匯總了C#中System.DateTimeResult.SetDate方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTimeResult.SetDate方法的具體用法?C# DateTimeResult.SetDate怎麽用?C# DateTimeResult.SetDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTimeResult
的用法示例。
在下文中一共展示了DateTimeResult.SetDate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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;
}
示例2: SetDateYMD
private static bool SetDateYMD(ref DateTimeResult result, int year, int month, int day)
{
if (result.calendar.IsValidDay(year, month, day, result.era))
{
result.SetDate(year, month, day);
return true;
}
return false;
}
示例3: 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;
}
示例4: SetDateYMD
private static bool SetDateYMD(ref DateTimeResult result, int year, int month, int day)
{
// Note, longer term these checks should be done at the end of the parse. This current
// way of checking creates order dependence with parsing the era name.
if (result.calendar.IsValidDay(year, month, day, result.era))
{
result.SetDate(year, month, day); // YMD
return (true);
}
return (false);
}
示例5: GetDayOfMNN
private static void GetDayOfMNN(DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
int n1 = raw.num[0];
int n2 = raw.num[1];
int order = GetYearMonthDayOrder(dtfi.ShortDatePattern, dtfi);
int year;
if (order == ORDER_MDY)
{
if (IsValidDay(result, year = AdjustYear(result, n2), raw.month, n1))
{
result.SetDate(year, raw.month, n1); // MDY
return;
}
else if (IsValidDay(result, year = AdjustYear(result, n1), raw.month, n2))
{
result.SetDate(year, raw.month, n2); // YMD
return;
}
}
else if (order == ORDER_YMD)
{
if (IsValidDay(result, year = AdjustYear(result, n1), raw.month, n2))
{
result.SetDate(year, raw.month, n2); // YMD
return;
}
else if (IsValidDay(result, year = AdjustYear(result, n2), raw.month, n1))
{
result.SetDate(year, raw.month, n1); // DMY
return;
}
}
else if (order == ORDER_DMY)
{
if (IsValidDay(result, year = AdjustYear(result, n2), raw.month, n1))
{
result.SetDate(year, raw.month, n1); // DMY
return;
}
else if (IsValidDay(result, year = AdjustYear(result, n1), raw.month, n2))
{
result.SetDate(year, raw.month, n2); // YMD
return;
}
}
throw new FormatException(Environment.GetResourceString("Format_BadDateTime"));
}
示例6: SetDateYMD
private static bool SetDateYMD(DateTimeResult result, int year, int month, int day)
{
if (IsValidMonth(result, year, month) && IsValidDay(result, year, month, day))
{
result.SetDate(year, month, day); // YMD
return (true);
}
return (false);
}