本文整理汇总了C#中System.Globalization.CultureInfo.Check方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.Check方法的具体用法?C# CultureInfo.Check怎么用?C# CultureInfo.Check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.Check方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EndOf
/// <summary>
/// End of a specific time frame
/// </summary>
/// <param name="Date">Date to base off of</param>
/// <param name="TimeFrame">Time frame to use</param>
/// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param>
/// <returns>The end of a specific time frame (TimeFrame.Day is the only one that sets the time to 12:59:59 PM, all else are the beginning of the day)</returns>
public static DateTime EndOf(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null)
{
Culture = Culture.Check(CultureInfo.CurrentCulture);
if (TimeFrame == TimeFrame.Day)
return new DateTime(Date.Year, Date.Month, Date.Day, 23, 59, 59);
if (TimeFrame == TimeFrame.Week)
return Date.BeginningOf(TimeFrame.Week, Culture).AddDays(6);
if (TimeFrame == TimeFrame.Month)
return Date.AddMonths(1).BeginningOf(TimeFrame.Month, Culture).AddDays(-1).Date;
if (TimeFrame == TimeFrame.Quarter)
return Date.EndOf(TimeFrame.Quarter, Date.BeginningOf(TimeFrame.Year, Culture), Culture);
return new DateTime(Date.Year, 12, 31);
}
示例2: DaysLeftIn
/// <summary>
/// Gets the number of days left in the time frame specified based on the date
/// </summary>
/// <param name="Date">Date</param>
/// <param name="TimeFrame">Time frame to calculate the number of days left</param>
/// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param>
/// <param name="StartOfQuarter1">Start of the first quarter</param>
/// <returns>The number of days left in the time frame</returns>
public static int DaysLeftIn(this DateTime Date, TimeFrame TimeFrame, DateTime StartOfQuarter1, CultureInfo Culture = null)
{
if (TimeFrame != TimeFrame.Quarter)
return Date.DaysLeftIn(TimeFrame, Culture);
Culture = Culture.Check(CultureInfo.CurrentCulture);
return Date.DaysIn(TimeFrame.Quarter, StartOfQuarter1, Culture) - (Date.DayOfYear - StartOfQuarter1.DayOfYear);
}
示例3: DaysIn
/// <summary>
/// Gets the number of days in the time frame specified based on the date
/// </summary>
/// <param name="Date">Date</param>
/// <param name="TimeFrame">Time frame to calculate the number of days from</param>
/// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param>
/// <returns>The number of days in the time frame</returns>
public static int DaysIn(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null)
{
Culture = Culture.Check(CultureInfo.CurrentCulture);
if (TimeFrame == TimeFrame.Day)
return 1;
if (TimeFrame == TimeFrame.Week)
return 7;
if (TimeFrame == TimeFrame.Month)
return Culture.Calendar.GetDaysInMonth(Date.Year, Date.Month);
if (TimeFrame == TimeFrame.Quarter)
return Date.EndOf(TimeFrame.Quarter, Culture).DayOfYear - Date.BeginningOf(TimeFrame.Quarter, Culture).DayOfYear;
return Culture.Calendar.GetDaysInYear(Date.Year);
}
示例4: BeginningOf
/// <summary>
/// Beginning of a specific time frame
/// </summary>
/// <param name="Date">Date to base off of</param>
/// <param name="TimeFrame">Time frame to use</param>
/// <param name="Culture">Culture to use for calculating (defaults to the current culture)</param>
/// <returns>The beginning of a specific time frame</returns>
public static DateTime BeginningOf(this DateTime Date, TimeFrame TimeFrame, CultureInfo Culture = null)
{
Culture = Culture.Check(CultureInfo.CurrentCulture);
if (TimeFrame == TimeFrame.Day)
return Date.Date;
if (TimeFrame == TimeFrame.Week)
return Date.AddDays(Culture.DateTimeFormat.FirstDayOfWeek - Date.DayOfWeek).Date;
if (TimeFrame == TimeFrame.Month)
return new DateTime(Date.Year, Date.Month, 1);
if (TimeFrame == TimeFrame.Quarter)
return Date.BeginningOf(TimeFrame.Quarter, Date.BeginningOf(TimeFrame.Year, Culture), Culture);
return new DateTime(Date.Year, 1, 1);
}
示例5: Singularize
/// <summary>
/// Singularizes a word
/// </summary>
/// <param name="Word">Word to singularize</param>
/// <param name="Culture">
/// Culture info used to singularize the word (defaults to current culture)
/// </param>
/// <returns>The word singularized</returns>
public static string Singularize(this string Word, CultureInfo Culture = null)
{
if (string.IsNullOrEmpty(Word))
return "";
Culture = Culture.Check(CultureInfo.CurrentCulture);
return PluralizationService.CreateService(Culture).Singularize(Word);
}