HebrewCalendar 类

定义

表示希伯来历。

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

示例

以下示例创建一个文件,其中包含 类支持的 HebrewCalendar 日期范围,并显示 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 对象的当前日历。 然后,它使希伯来语 (以色列) 目前的文化。 这会导致公共语言运行时解释与希伯来语日历相关的所有日期和时间。

注解

希伯来历识别两个纪元:B.C.E. (之前共同时代) 和A.M. (拉丁语“Anno Mundi”,意思是“世界之年”) 。 类的 HebrewCalendar 此实现仅识别公历) 中当前纪元 (A.M.) 和希伯来语年 5343 到 5999 (1583 到 2239。

注意

有关在.NET Framework中使用 HebrewCalendar 类和其他日历类的信息,请参阅使用日历

在以 19 年均匀除数的年份结束的每个 19 年周期中,第 3 年、6 年、8 年、11 年、14 年、第 17 年和 19 年是闰年。 一个普通年份可能有 353 到 355 天,具体取决于犹太节日的安排。 闰年可以有 383 到 385 天。

希伯来历法在普通年份有 12 个月,闰年有 13 个月:

获取常见年份) (月值 获取闰年) (月值 Month 普通年份的天数 闰年中的天数
1 1 תשרי (Tishrei) 30 30
2 2 חשון (切什万) 29/30 29/30
3 3 כסלו (Kislev) 29/30 29/30
4 4 טבת (Tevet) 29 29
5 5 שבט (谢瓦特) 30 30
6 - אדר (Adar) 29 -
- 6 אדר א (Adar Alef) - 30
- 7 אדר ב (阿达尔·贝特) - 29
7 8 ניסן (日产) 30 30
8 9 אייר (Iyar) 29 29
9 10 סיון (Sivan) 30 30
10 11 תמוז (Tamuz) 29 29
11 12 אב (Av) 30 30
12 13 אלול (Elul) 29 29

切什万和基斯列夫的日子因犹太节日的安排而异。 在闰年,Adar 被 Adar Alef 替换为 30 天,Adar Beit 替换为 29 天。 阿达尔·阿莱夫被认为是闰月。 阿达尔·阿勒夫的最后一天和阿达尔贝特的所有日子都被认为是闰日:也就是说, IsLeapDay 方法将返回 true 这些天。

公历中的 2001 年 1 月 1 日日期相当于希伯来历中 5761 年特维特的第六天。

每个都 CultureInfo 支持一组日历。 属性 Calendar 返回区域性的默认日历,属性 OptionalCalendars 返回包含区域性支持的所有日历的数组。 若要更改 使用的CultureInfo日历,应用程序应将 的 CultureInfo.DateTimeFormat 属性设置为Calendar新的 Calendar

构造函数

HebrewCalendar()

初始化 HebrewCalendar 类的新实例。

字段

CurrentEra

表示当前日历的当前纪元。 字段的值为 0。

(继承自 Calendar)
HebrewEra

表示当前纪元。 此字段为常数。

属性

AlgorithmType

获取一个值,该值指示当前日历是阳历、阴历还是二者的组合。

AlgorithmType

获取一个值,该值指示当前日历是阳历、阴历还是二者的组合。

(继承自 Calendar)
DaysInYearBeforeMinSupportedYear

获取 MinSupportedDateTime 属性指定的年份之前的年中天数。

(继承自 Calendar)
Eras

获取 HebrewCalendar 中的纪元列表。

IsReadOnly

获取一个值,该值指示此 Calendar 对象是否为只读。

(继承自 Calendar)
MaxSupportedDateTime

获取 HebrewCalendar 类型支持的最晚日期和时间。

MaxSupportedDateTime

获取此 Calendar 对象支持的最晚日期和时间。

(继承自 Calendar)
MinSupportedDateTime

获取 HebrewCalendar 类型支持的最早日期和时间。

MinSupportedDateTime

获取此 Calendar 对象支持的最早日期和时间。

(继承自 Calendar)
TwoDigitYearMax

获取或设置可以用两位数年份表示的 100 年范围内的最后一年。

方法

AddDays(DateTime, Int32)

返回与指定 DateTime 相距指定天数的 DateTime

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

返回与指定 DateTime 相距指定小时数的 DateTime

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

返回与指定 DateTime 相距指定毫秒数的 DateTime

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

返回与指定 DateTime 相距指定分钟数的 DateTime

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

返回与指定 DateTime 相距指定月数的 DateTime

AddSeconds(DateTime, Int32)

返回与指定 DateTime 相距指定秒数的 DateTime

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

返回与指定 DateTime 相距指定周数的 DateTime

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

返回与指定 DateTime 相距指定年数的 DateTime

Clone()

创建表示当前 Calendar 对象副本的新对象。

(继承自 Calendar)
Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetDayOfMonth(DateTime)

返回指定 DateTime 中的月中日期。

GetDayOfWeek(DateTime)

返回指定 DateTime 中的周中日期。

GetDayOfYear(DateTime)

返回指定 DateTime 中的日期是该年中的第几天。

GetDaysInMonth(Int32, Int32)

返回当前纪元的指定月份和年份中的天数。

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

返回指定纪元中指定年份的指定月份中的天数。

GetDaysInYear(Int32)

返回当前纪元中指定年份的天数。

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

返回指定纪元中指定年份的天数。

GetEra(DateTime)

返回指定 DateTime 中的纪元。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetHour(DateTime)

返回指定 DateTime 中的小时值。

(继承自 Calendar)
GetLeapMonth(Int32)

计算指定年份的闰月。

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

计算指定纪元年份的闰月。

GetLeapMonth(Int32, Int32)

计算指定纪元年份的闰月。

(继承自 Calendar)
GetMilliseconds(DateTime)

返回指定 DateTime 中的毫秒值。

(继承自 Calendar)
GetMinute(DateTime)

返回指定 DateTime 中的分钟值。

(继承自 Calendar)
GetMonth(DateTime)

返回指定 DateTime 中的月份。

GetMonthsInYear(Int32)

返回当前纪元中指定年份的月数。

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

返回指定纪元中指定年份的月数。

GetSecond(DateTime)

返回指定 DateTime 中的秒值。

(继承自 Calendar)
GetType()

获取当前实例的 Type

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

返回一年中包含指定 DateTime 值中的日期的那个星期。

(继承自 Calendar)
GetYear(DateTime)

返回指定 DateTime 值中的年份。

IsLeapDay(Int32, Int32, Int32)

确定当前纪元中的指定日期是否为闰日。

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

确定指定纪元中的指定日期是否为闰日。

IsLeapMonth(Int32, Int32)

确定当前纪元中指定年份的指定月份是否为闰月。

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

确定指定纪元中指定年份的指定月份是否为闰月。

IsLeapYear(Int32)

确定当前纪元中的指定年份是否为闰年。

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

确定指定纪元中的指定年份是否为闰年。

MemberwiseClone()

创建当前 Object 的浅表副本。

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

返回设置为当前纪元中指定日期和时间的 DateTime

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

返回设置为指定纪元中指定日期和时间的 DateTime

ToFourDigitYear(Int32)

使用 TwoDigitYearMax 属性将指定的年份转换为四位数年份,以确定相应的纪元。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅