Udostępnij za pośrednictwem


UmAlQuraCalendar.GetDaysInYear Method (Int32, Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Updated: October 2010

Calculates the number of days in the specified year of the specified era.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overrides Function GetDaysInYear ( _
    year As Integer, _
    era As Integer _
) As Integer
public override int GetDaysInYear(
    int year,
    int era
)

Parameters

  • era
    Type: System.Int32
    An era. Specify UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra].

Return Value

Type: System.Int32
The number of days in the specified year and era. The number of days is 354 in a common year or 355 in a leap year.

Exceptions

Exception Condition
ArgumentOutOfRangeException

year or era is outside the range supported by the UmAlQuraCalendar class.

Examples

The following example calls the GetDaysInYear method to get the number of days in ten consecutive years in each era supported by the UmAlQuraCalendar class.

Imports System.Globalization

Module Example
   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim cal As New UmAlQuraCalendar()
      Dim currentYear As Integer = cal.GetYear(Date.Now)

      outputBlock.Text &= "Era     Year     Days" & vbCrLf
      outputBlock.Text &= vbCrLf
      For Each era As Integer In cal.Eras
         For year As Integer = currentYear To currentYear + 9
            outputBlock.Text += String.Format("{0}{1}      {2}      {3}",  
                              ShowCurrentEra(cal, era), era, year, 
                              cal.GetDaysInYear(year, era)) & vbCrLf  
         Next
      Next
      outputBlock.Text &= vbCrLf
      outputBlock.Text &= "   * Indicates the current era." & vbCrLf
   End Sub

   Private Function ShowCurrentEra(ByVal cal As Calendar, ByVal era As Integer) As String
      If era = cal.Eras(Calendar.CurrentEra) Then
         Return "*"
      Else
         Return " "
      End If
   End Function
End Module
' The example displays the following output:
'       Era     Year     Days
'       
'       *1      1431      354
'       *1      1432      354
'       *1      1433      355
'       *1      1434      354
'       *1      1435      355
'       *1      1436      354
'       *1      1437      354
'       *1      1438      354
'       *1      1439      355
'       *1      1440      354
'       
'          * Indicates the current era.
using System;
using System.Globalization;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Calendar cal = new UmAlQuraCalendar();
      int currentYear = cal.GetYear(DateTime.Now);

      outputBlock.Text += "Era     Year     Days\n" + "\n";
      foreach (int era in cal.Eras)
      {
         for (int year = currentYear; year <= currentYear + 9; year++)
         {
            outputBlock.Text += String.Format("{0}{1}      {2}      {3}",
                              ShowCurrentEra(cal, era), era, year,
                              cal.GetDaysInYear(year, era)) + "\n";
         }
      }
      outputBlock.Text += "\n   * Indicates the current era." + "\n";
   }

   private static string ShowCurrentEra(Calendar cal, int era)
   {
      if (era == cal.Eras[Calendar.CurrentEra])
         return "*";
      else
         return " ";
   }
}
// The example displays the following output:
//       Era     Year     Days
//       
//       *1      1431      354
//       *1      1432      354
//       *1      1433      355
//       *1      1434      354
//       *1      1435      355
//       *1      1436      354
//       *1      1437      354
//       *1      1438      354
//       *1      1439      355
//       *1      1440      354
//       
//          * Indicates the current era.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Change History

Date

History

Reason

October 2010

Corrected return value information and replaced the example.

Customer feedback.