本文整理汇总了C#中System.Globalization.DateTimeFormatInfo.internalGetLeapYearMonthNames方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.internalGetLeapYearMonthNames方法的具体用法?C# DateTimeFormatInfo.internalGetLeapYearMonthNames怎么用?C# DateTimeFormatInfo.internalGetLeapYearMonthNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.internalGetLeapYearMonthNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchMonthName
/*=================================MatchMonthName==================================
**Action: Parse the month name from string starting at str.Index.
**Returns: A value from 1 to 12 indicating the first month to the twelveth month.
**Arguments: str: a __DTString. The parsing will start from the
** next character after str.Index.
**Exceptions: FormatException if a month name can not be found.
==============================================================================*/
private static bool MatchMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result) {
int maxMatchStrLen = 0;
result = -1;
if (str.GetNext()) {
//
// Scan the month names (note that some calendars has 13 months) and find
// the matching month name which has the max string length.
// We need to do this because some cultures (e.g. "vi-VN") which have
// month names with the same prefix.
//
int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12: 13);
for (int i = 1; i <= monthsInYear; i++) {
String searchStr = dtfi.GetMonthName(i);
int matchStrLen = searchStr.Length;
if ( dtfi.HasSpacesInMonthNames
? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen)
: str.MatchSpecifiedWord(searchStr)) {
if (matchStrLen > maxMatchStrLen) {
maxMatchStrLen = matchStrLen;
result = i;
}
}
}
// Search genitive form.
if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != 0) {
int tempResult = str.MatchLongestWords(dtfi.MonthGenitiveNames, ref maxMatchStrLen);
// We found a longer match in the genitive month name. Use this as the result.
// The result from MatchLongestWords is 0 ~ length of word array.
// So we increment the result by one to become the month value.
if (tempResult >= 0) {
result = tempResult + 1;
}
}
// Search leap year form.
if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != 0) {
int tempResult = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref maxMatchStrLen);
// We found a longer match in the leap year month name. Use this as the result.
// The result from MatchLongestWords is 0 ~ length of word array.
// So we increment the result by one to become the month value.
if (tempResult >= 0) {
result = tempResult + 1;
}
}
}
if (result > 0) {
str.Index += (maxMatchStrLen - 1);
return (true);
}
return false;
}
示例2: MatchMonthName
private static bool MatchMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result)
{
int num = 0;
result = -1;
if (str.GetNext())
{
int num2 = (dtfi.GetMonthName(13).Length == 0) ? 12 : 13;
for (int i = 1; i <= num2; i++)
{
string monthName = dtfi.GetMonthName(i);
int length = monthName.Length;
if ((dtfi.HasSpacesInMonthNames ? str.MatchSpecifiedWords(monthName, false, ref length) : str.MatchSpecifiedWord(monthName)) && length > num)
{
num = length;
result = i;
}
}
if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != DateTimeFormatFlags.None)
{
int num3 = str.MatchLongestWords(dtfi.MonthGenitiveNames, ref num);
if (num3 >= 0)
{
result = num3 + 1;
}
}
if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != DateTimeFormatFlags.None)
{
int num4 = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref num);
if (num4 >= 0)
{
result = num4 + 1;
}
}
}
if (result > 0)
{
str.Index += num - 1;
return true;
}
return false;
}
示例3: MatchAbbreviatedMonthName
private static bool MatchAbbreviatedMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result)
{
int maxMatchStrLen = 0;
result = -1;
if (str.GetNext())
{
int num2 = (dtfi.GetMonthName(13).Length == 0) ? 12 : 13;
for (int i = 1; i <= num2; i++)
{
string abbreviatedMonthName = dtfi.GetAbbreviatedMonthName(i);
int length = abbreviatedMonthName.Length;
if ((dtfi.HasSpacesInMonthNames ? str.MatchSpecifiedWords(abbreviatedMonthName, false, ref length) : str.MatchSpecifiedWord(abbreviatedMonthName)) && (length > maxMatchStrLen))
{
maxMatchStrLen = length;
result = i;
}
}
if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != DateTimeFormatFlags.None)
{
int num5 = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref maxMatchStrLen);
if (num5 >= 0)
{
result = num5 + 1;
}
}
}
if (result > 0)
{
str.Index += maxMatchStrLen - 1;
return true;
}
return false;
}