當前位置: 首頁>>代碼示例>>C#>>正文


C# CultureInfo.Check方法代碼示例

本文整理匯總了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);
 }
開發者ID:kaytie,項目名稱:Craig-s-Utility-Library,代碼行數:20,代碼來源:DateTimeExtensions.cs

示例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);
 }
開發者ID:kaytie,項目名稱:Craig-s-Utility-Library,代碼行數:15,代碼來源:DateTimeExtensions.cs

示例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);
 }
開發者ID:kaytie,項目名稱:Craig-s-Utility-Library,代碼行數:20,代碼來源:DateTimeExtensions.cs

示例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);
 }
開發者ID:kaytie,項目名稱:Craig-s-Utility-Library,代碼行數:20,代碼來源:DateTimeExtensions.cs

示例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);
 }
開發者ID:modulexcite,項目名稱:Craig-s-Utility-Library,代碼行數:15,代碼來源:StringExtensions.cs


注:本文中的System.Globalization.CultureInfo.Check方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。