HebrewCalendar 类

定义

表示希伯来历。Represents the Hebrew calendar.

public ref class HebrewCalendar : System::Globalization::Calendar
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class HebrewCalendar : System.Globalization.Calendar
type HebrewCalendar = class
    inherit Calendar
Public Class HebrewCalendar
Inherits Calendar
继承
HebrewCalendar
属性

示例

下面的示例创建一个文件, 其中包含HebrewCalendar类支持的日期范围, 并显示5772年每个月的天数。The following example creates a file that contains the date ranges supported by the HebrewCalendar class, and displays the number of days in each month of the year 5772.

using System;
using System.Globalization;
using System.IO;
using System.Threading;

public class Example
{
   public static void Main()
   {
      StreamWriter output = new StreamWriter("HebrewCalendarInfo.txt");
      
      // Make the Hebrew Calendar the current calendar and
      // Hebrew (Israel) the current thread culture.
      HebrewCalendar hc = new HebrewCalendar();
      CultureInfo culture = CultureInfo.CreateSpecificCulture("he-IL");
      culture.DateTimeFormat.Calendar = hc;
      Thread.CurrentThread.CurrentCulture = culture;
      
      output.WriteLine("{0} Information:\n", 
                       GetCalendarName(culture.DateTimeFormat.Calendar));
      
      // Get the calendar range expressed in both Hebrew calendar and
      // Gregorian calendar dates.
      output.WriteLine("Start Date: {0} ", hc.MinSupportedDateTime);  
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("            ({0} Gregorian)\n", 
                       hc.MinSupportedDateTime);
      
      culture.DateTimeFormat.Calendar = hc;
      output.WriteLine("End Date: {0} ", hc.MaxSupportedDateTime);
      culture.DateTimeFormat.Calendar = culture.Calendar;
      output.WriteLine("          ({0} Gregorian)\n", 
                       hc.MaxSupportedDateTime);  
      
      culture.DateTimeFormat.Calendar = hc;
      
      // Get the year in the Hebrew calendar that corresponds to 1/1/2012
      // and display information about it.
      DateTime startOfYear = new DateTime(2012, 1, 1);
      output.WriteLine("Days in the Year {0}: {1}\n", 
                       hc.GetYear(startOfYear), 
                       hc.GetDaysInYear(hc.GetYear(startOfYear)));
      
      output.WriteLine("Days in Each Month of {0}:\n", hc.GetYear(startOfYear));
      output.WriteLine("Month       Days       Month Name");
      // Change start of year to first day of first month 
      startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0);
      DateTime startOfMonth = startOfYear;
      for (int ctr = 1; ctr <= hc.GetMonthsInYear(hc.GetYear(startOfYear)); ctr++) { 
         output.Write(" {0,2}", ctr);
         output.WriteLine("{0,12}{1,15:MMM}", 
                          hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)),
                          startOfMonth);  
         startOfMonth = hc.AddMonths(startOfMonth, 1);                 
      } 
                                     
      output.Close();          
   }

   private static string GetCalendarName(Calendar cal) 
   {
      return cal.ToString().Replace("System.Globalization.", "").Replace("Cal", " Cal");
   }
}
// The example displays the following output:
//       Hebrew Calendar Information:
//       
//       Start Date: ז// טבת שמ"ג 00:00:00 
//                   (01/01/1583 00:00:00 Gregorian)
//       
//       End Date: כ"ט אלול תתקצ"ט 23:59:59 
//                 (29/09/2239 23:59:59 Gregorian)
//       
//       Days in the Year 5772: 354
//       
//       Days in Each Month of 5772:
//       
//       Month       Days       Month Name
//         1          30           תשרי
//         2          29           חשון
//         3          30           כסלו
//         4          29            טבת
//         5          30            שבט
//         6          29            אדר
//         7          30           ניסן
//         8          29           אייר
//         9          30           סיון
//        10          29           תמוז
//        11          30             אב
//        12          29           אלול
Imports System.Globalization
Imports System.IO
Imports System.Threading

Module Example
   Public Sub Main()
      Dim output As New StreamWriter("HebrewCalendarInfo.txt")
      
      ' Make the Hebrew Calendar the current calendar and
      ' Hebrew (Israel) the current thread culture.
      Dim hc As New HebrewCalendar()
      Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("he-IL")
      culture.DateTimeFormat.Calendar = hc
      Thread.CurrentThread.CurrentCulture = culture
      
      output.WriteLine("{0} Information:", 
                       GetCalendarName(culture.DateTimeFormat.Calendar))
      output.WriteLine()
      
      ' Get the calendar range expressed in both Hebrew calendar and
      ' Gregorian calendar dates.
      output.WriteLine("Start Date: {0} ", 
                       hc.MinSupportedDateTime)  
      culture.DateTimeFormat.Calendar = culture.Calendar
      output.WriteLine("            ({0} Gregorian)", 
                       hc.MinSupportedDateTime)
      output.WriteLine()
      
      culture.DateTimeFormat.Calendar = hc
      output.WriteLine("End Date: {0} ", 
                   hc.MaxSupportedDateTime)
      culture.DateTimeFormat.Calendar = culture.Calendar
      output.WriteLine("          ({0} Gregorian)", 
                       hc.MaxSupportedDateTime)  
      output.WriteLine()
      
      culture.DateTimeFormat.Calendar = hc
      
      ' Get the year in the Hebrew calendar that corresponds to 1/1/2012
      ' and display information about it.
      Dim startOfYear As Date = #1/1/2012#
      output.WriteLine("Days in the Year {0}: {1}", 
                       hc.GetYear(startOfYear), 
                       hc.GetDaysInYear(hc.GetYear(startOfYear)))
      output.WriteLine()
      
      output.WriteLine("Days in Each Month of {0}:", hc.GetYear(startOfYear))
      output.WriteLine()
      output.WriteLine("Month       Days       Month Name")
      ' Change start of year to first day of first month 
      startOfYear = hc.ToDateTime(hc.GetYear(startOfYear), 1, 1, 0, 0, 0, 0)
      Dim startOfMonth As Date = startOfYear
      For ctr As Integer = 1 To hc.GetMonthsInYear(hc.GetYear(startOfYear)) 
         output.Write(" {0,2}", ctr)
         output.WriteLine("{0,12}{1,15:MMM}", 
                          hc.GetDaysInMonth(hc.GetYear(startOfMonth), hc.GetMonth(startOfMonth)),
                          startOfMonth)  
         startOfMonth = hc.AddMonths(startOfMonth, 1)                 
      Next 
                                     
      output.Close()          
   End Sub
   
   Private Function GetCalendarName(cal As Calendar) As String
      Return cal.ToString().Replace("System.Globalization.", "").Replace("Cal", " Cal")
   End Function
End Module
' The example displays the following output:
'       Hebrew Calendar Information:
'       
'       Start Date: ז' טבת שמ"ג 00:00:00 
'                   (01/01/1583 00:00:00 Gregorian)
'       
'       End Date: כ"ט אלול תתקצ"ט 23:59:59 
'                 (29/09/2239 23:59:59 Gregorian)
'       
'       Days in the Year 5772: 354
'       
'       Days in Each Month of 5772:
'       
'       Month       Days       Month Name
'         1          30           תשרי
'         2          29           חשון
'         3          30           כסלו
'         4          29            טבת
'         5          30            שבט
'         6          29            אדר
'         7          30           ניסן
'         8          29           אייר
'         9          30           סיון
'        10          29           תמוז
'        11          30             אב
'        12          29           אלול

该示例实例化HebrewCalendar一个对象, 并使其成为希伯来语 (以色列) CultureInfo对象的当前日历。The example instantiates a HebrewCalendar object and makes it the current calendar of a Hebrew (Israel) CultureInfo object. 然后, 它使希伯来语 (以色列) 成为当前线程的区域性。It then makes Hebrew (Israel) the current thread culture. 这会导致公共语言运行时解释与希伯来历相关的所有日期和时间。This causes the common language runtime to interpret all dates and times in relation to the Hebrew calendar.

注解

希伯来语可识别两个纪元:B.C.E.The Hebrew calendar recognizes two eras: B.C.E. (在 common 年代之前) 和早上(before the common era) and A.M. ("基督 Mundi", 这意味着 "世界年")。(Latin "Anno Mundi", which means "the year of the world"). HebrewCalendar类实现仅识别当前纪元和希伯来年5343到 5999 (公历的1583为 2239)。This implementation of the HebrewCalendar class recognizes only the current era (A.M.) and the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar).

备注

有关使用 .NET Framework 中的HebrewCalendar类和其他 calendar 类的信息, 请参阅使用日历For information about using the HebrewCalendar class and the other calendar classes in the .NET Framework, see Working with Calendars.

在每个以19为间隔的年份结束的每个19年循环中, 第三、第六、第8、第11、第14、第17和第19年是闰年。In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. 一年的时间可能为353到355天, 具体取决于 Jewish 假日的位置。A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. 闰年的时间可能为383到385天。A leap year can have from 383 to 385 days.

希伯来历在常见年份有12个月, 在闰年中有13个月:The Hebrew calendar has 12 months during common years and 13 months during leap years:

GetMonth 值 (通用年份)GetMonth value (common year) GetMonth 值 (leap 年份)GetMonth value (leap year) 月份Month 常见年份中的天数Days in common years 闰年中的天数Days in leap years
11 11 תשרי (Tishrei)תשרי (Tishrei) 3030 3030
22 22 חשון (Cheshvan)חשון (Cheshvan) 29/3029/30 29/3029/30
33 33 כסלו (Kislev)כסלו (Kislev) 29/3029/30 29/3029/30
44 44 טבת (Tevet)טבת (Tevet) 2929 2929
55 55 שבט (Shevat)שבט (Shevat) 3030 3030
66 - אדר (Adar)אדר (Adar) 2929 -
- 66 אדרא (Adar)אדר א (Adar Alef) - 3030
- 77 אדר ב (Adar Beit)אדר ב (Adar Beit) - 2929
77 88 ניסן (Nissan)ניסן (Nissan) 3030 3030
88 99 אייר (Iyar)אייר (Iyar) 2929 2929
99 1010 סיון (Sivan)סיון (Sivan) 3030 3030
1010 1111 תמוז (Tamuz)תמוז (Tamuz) 2929 2929
1111 1212 אב (Av)אב (Av) 3030 3030
1212 1313 אלול (Elul)אלול (Elul) 2929 2929

Cheshvan 和 Kislev 中的日期因 Jewish 假日的位置而异。The days in Cheshvan and Kislev vary depending on the placement of Jewish holidays. 在闰年期间, Adar 被 Adar Alef 替换为30天, Adar Beit 替换为29天。During leap years, Adar is replaced by Adar Alef with 30 days and Adar Beit with 29 days. Adar Alef 被视为闰年。Adar Alef is considered the leap month. Adar Alef 和 Adar Beit 中的所有天的最后一天都被视为闰日;也就是说, 该方法IsLeapDay将在true这天后返回。The last day of Adar Alef and all the days in Adar Beit are considered leap days; that is, the IsLeapDay method returns true for these days.

日期公元2001年1月1日The date January 1, 2001 A.D. 在公历中, 相当于5761年凌晨年 Tevet 的第六天。in the Gregorian calendar is equivalent to the sixth day of Tevet in the year 5761 A.M. 在希伯来日历中。in the Hebrew calendar.

CultureInfo个都支持一组日历。Each CultureInfo supports a set of calendars. 属性返回区域性的默认日历, OptionalCalendars属性返回一个数组, 该数组包含该区域性支持的所有日历。 CalendarThe Calendar property returns the default calendar for the culture, and the OptionalCalendars property returns an array containing all the calendars supported by the culture. CultureInfo若要更改使用的日历, 应用程序应Calendar将的属性CultureInfo.DateTimeFormat设置为新Calendar的。To change the calendar used by a CultureInfo, the application should set the Calendar property of CultureInfo.DateTimeFormat to a new Calendar.

构造函数

HebrewCalendar()

初始化 HebrewCalendar 类的新实例。Initializes a new instance of the HebrewCalendar class.

字段

CurrentEra

表示当前日历的当前纪元。Represents the current era of the current calendar. 字段的值为 0。The value of this field is 0.

(继承自 Calendar)
HebrewEra

表示当前纪元。Represents the current era. 此字段为常数。This field is constant.

属性

AlgorithmType

获取一个值,该值指示当前日历是阳历、阴历还是二者的组合。Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both.

DaysInYearBeforeMinSupportedYear

获取 MinSupportedDateTime 属性指定的年份之前的年中天数。Gets the number of days in the year that precedes the year that is specified by the MinSupportedDateTime property.

(继承自 Calendar)
Eras

获取 HebrewCalendar 中的纪元列表。Gets the list of eras in the HebrewCalendar.

IsReadOnly

获取一个值,该值指示此 Calendar 对象是否为只读。Gets a value indicating whether this Calendar object is read-only.

(继承自 Calendar)
MaxSupportedDateTime

获取 HebrewCalendar 类型支持的最晚日期和时间。Gets the latest date and time supported by the HebrewCalendar type.

MinSupportedDateTime

获取 HebrewCalendar 类型支持的最早日期和时间。Gets the earliest date and time supported by the HebrewCalendar type.

TwoDigitYearMax

获取或设置可以用两位数年份表示的 100 年范围内的最后一年。Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.

方法

AddDays(DateTime, Int32)

返回与指定 DateTime 相距指定天数的 DateTimeReturns a DateTime that is the specified number of days away from the specified DateTime.

(继承自 Calendar)
AddHours(DateTime, Int32)

返回与指定 DateTime 相距指定小时数的 DateTimeReturns a DateTime that is the specified number of hours away from the specified DateTime.

(继承自 Calendar)
AddMilliseconds(DateTime, Double)

返回与指定 DateTime 相距指定毫秒数的 DateTimeReturns a DateTime that is the specified number of milliseconds away from the specified DateTime.

(继承自 Calendar)
AddMinutes(DateTime, Int32)

返回与指定 DateTime 相距指定分钟数的 DateTimeReturns a DateTime that is the specified number of minutes away from the specified DateTime.

(继承自 Calendar)
AddMonths(DateTime, Int32)

返回与指定 DateTime 相距指定月数的 DateTimeReturns a DateTime that is the specified number of months away from the specified DateTime.

AddSeconds(DateTime, Int32)

返回与指定 DateTime 相距指定秒数的 DateTimeReturns a DateTime that is the specified number of seconds away from the specified DateTime.

(继承自 Calendar)
AddWeeks(DateTime, Int32)

返回与指定 DateTime 相距指定周数的 DateTimeReturns a DateTime that is the specified number of weeks away from the specified DateTime.

(继承自 Calendar)
AddYears(DateTime, Int32)

返回与指定 DateTime 相距指定年数的 DateTimeReturns a DateTime that is the specified number of years away from the specified DateTime.

Clone()

创建表示当前 Calendar 对象副本的新对象。Creates a new object that is a copy of the current Calendar object.

(继承自 Calendar)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetDayOfMonth(DateTime)

返回指定 DateTime 中的月中日期。Returns the day of the month in the specified DateTime.

GetDayOfWeek(DateTime)

返回指定 DateTime 中的周中日期。Returns the day of the week in the specified DateTime.

GetDayOfYear(DateTime)

返回指定 DateTime 中的日期是该年中的第几天。Returns the day of the year in the specified DateTime.

GetDaysInMonth(Int32, Int32)

返回当前纪元的指定月份和年份中的天数。Returns the number of days in the specified month and year of the current era.

(继承自 Calendar)
GetDaysInMonth(Int32, Int32, Int32)

返回指定纪元中指定年份的指定月份中的天数。Returns the number of days in the specified month in the specified year in the specified era.

GetDaysInYear(Int32)

返回当前纪元中指定年份的天数。Returns the number of days in the specified year of the current era.

(继承自 Calendar)
GetDaysInYear(Int32, Int32)

返回指定纪元中指定年份的天数。Returns the number of days in the specified year in the specified era.

GetEra(DateTime)

返回指定 DateTime 中的纪元。Returns the era in the specified DateTime.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetHour(DateTime)

返回指定 DateTime 中的小时值。Returns the hours value in the specified DateTime.

(继承自 Calendar)
GetLeapMonth(Int32)

计算指定年份的闰月。Calculates the leap month for a specified year.

(继承自 Calendar)
GetLeapMonth(Int32, Int32)

计算指定纪元年份的闰月。Calculates the leap month for a specified year and era.

GetMilliseconds(DateTime)

返回指定 DateTime 中的毫秒值。Returns the milliseconds value in the specified DateTime.

(继承自 Calendar)
GetMinute(DateTime)

返回指定 DateTime 中的分钟值。Returns the minutes value in the specified DateTime.

(继承自 Calendar)
GetMonth(DateTime)

返回指定 DateTime 中的月份。Returns the month in the specified DateTime.

GetMonthsInYear(Int32)

返回当前纪元中指定年份的月数。Returns the number of months in the specified year in the current era.

(继承自 Calendar)
GetMonthsInYear(Int32, Int32)

返回指定纪元中指定年份的月数。Returns the number of months in the specified year in the specified era.

GetSecond(DateTime)

返回指定 DateTime 中的秒值。Returns the seconds value in the specified DateTime.

(继承自 Calendar)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

返回一年中包含指定 DateTime 值中的日期的那个星期。Returns the week of the year that includes the date in the specified DateTime value.

(继承自 Calendar)
GetYear(DateTime)

返回指定 DateTime 值中的年份。Returns the year in the specified DateTime value.

IsLeapDay(Int32, Int32, Int32)

确定当前纪元中的指定日期是否为闰日。Determines whether the specified date in the current era is a leap day.

(继承自 Calendar)
IsLeapDay(Int32, Int32, Int32, Int32)

确定指定纪元中的指定日期是否为闰日。Determines whether the specified date in the specified era is a leap day.

IsLeapMonth(Int32, Int32)

确定当前纪元中指定年份的指定月份是否为闰月。Determines whether the specified month in the specified year in the current era is a leap month.

(继承自 Calendar)
IsLeapMonth(Int32, Int32, Int32)

确定指定纪元中指定年份的指定月份是否为闰月。Determines whether the specified month in the specified year in the specified era is a leap month.

IsLeapYear(Int32)

确定当前纪元中的指定年份是否为闰年。Determines whether the specified year in the current era is a leap year.

(继承自 Calendar)
IsLeapYear(Int32, Int32)

确定指定纪元中的指定年份是否为闰年。Determines whether the specified year in the specified era is a leap year.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

返回设置为当前纪元中指定日期和时间的 DateTimeReturns a DateTime that is set to the specified date and time in the current era.

(继承自 Calendar)
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

返回设置为指定纪元中指定日期和时间的 DateTimeReturns a DateTime that is set to the specified date and time in the specified era.

ToFourDigitYear(Int32)

使用 TwoDigitYearMax 属性将指定的年份转换为四位数年份,以确定相应的纪元。Converts the specified year to a 4-digit year by using the TwoDigitYearMax property to determine the appropriate century.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅