Calendar Class

Calendar Class

 

Represents time in divisions, such as weeks, months, and years.

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


[<AbstractClass>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type Calendar = 
    class
        interface ICloneable
    end

NameDescription
System_CAPS_protmethodCalendar()

Initializes a new instance of the Calendar class.

NameDescription
System_CAPS_pubpropertyAlgorithmType

Gets a value indicating whether the current calendar is solar-based, lunar-based, or a combination of both.

System_CAPS_protpropertyDaysInYearBeforeMinSupportedYear

Gets the number of days in the year that precedes the year that is specified by the MinSupportedDateTime property.

System_CAPS_pubpropertyEras

When overridden in a derived class, gets the list of eras in the current calendar.

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether this Calendar object is read-only.

System_CAPS_pubpropertyMaxSupportedDateTime

Gets the latest date and time supported by this Calendar object.

System_CAPS_pubpropertyMinSupportedDateTime

Gets the earliest date and time supported by this Calendar object.

System_CAPS_pubpropertyTwoDigitYearMax

Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.

NameDescription
System_CAPS_pubmethodAddDays(DateTime, Int32)

Returns a DateTime that is the specified number of days away from the specified DateTime.

System_CAPS_pubmethodAddHours(DateTime, Int32)

Returns a DateTime that is the specified number of hours away from the specified DateTime.

System_CAPS_pubmethodAddMilliseconds(DateTime, Double)

Returns a DateTime that is the specified number of milliseconds away from the specified DateTime.

System_CAPS_pubmethodAddMinutes(DateTime, Int32)

Returns a DateTime that is the specified number of minutes away from the specified DateTime.

System_CAPS_pubmethodAddMonths(DateTime, Int32)

When overridden in a derived class, returns a DateTime that is the specified number of months away from the specified DateTime.

System_CAPS_pubmethodAddSeconds(DateTime, Int32)

Returns a DateTime that is the specified number of seconds away from the specified DateTime.

System_CAPS_pubmethodAddWeeks(DateTime, Int32)

Returns a DateTime that is the specified number of weeks away from the specified DateTime.

System_CAPS_pubmethodAddYears(DateTime, Int32)

When overridden in a derived class, returns a DateTime that is the specified number of years away from the specified DateTime.

System_CAPS_pubmethodClone()

Creates a new object that is a copy of the current Calendar object.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetDayOfMonth(DateTime)

When overridden in a derived class, returns the day of the month in the specified DateTime.

System_CAPS_pubmethodGetDayOfWeek(DateTime)

When overridden in a derived class, returns the day of the week in the specified DateTime.

System_CAPS_pubmethodGetDayOfYear(DateTime)

When overridden in a derived class, returns the day of the year in the specified DateTime.

System_CAPS_pubmethodGetDaysInMonth(Int32, Int32)

Returns the number of days in the specified month and year of the current era.

System_CAPS_pubmethodGetDaysInMonth(Int32, Int32, Int32)

When overridden in a derived class, returns the number of days in the specified month, year, and era.

System_CAPS_pubmethodGetDaysInYear(Int32)

Returns the number of days in the specified year of the current era.

System_CAPS_pubmethodGetDaysInYear(Int32, Int32)

When overridden in a derived class, returns the number of days in the specified year and era.

System_CAPS_pubmethodGetEra(DateTime)

When overridden in a derived class, returns the era in the specified DateTime.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetHour(DateTime)

Returns the hours value in the specified DateTime.

System_CAPS_pubmethodGetLeapMonth(Int32)

Calculates the leap month for a specified year.

System_CAPS_pubmethodGetLeapMonth(Int32, Int32)

Calculates the leap month for a specified year and era.

System_CAPS_pubmethodGetMilliseconds(DateTime)

Returns the milliseconds value in the specified DateTime.

System_CAPS_pubmethodGetMinute(DateTime)

Returns the minutes value in the specified DateTime.

System_CAPS_pubmethodGetMonth(DateTime)

When overridden in a derived class, returns the month in the specified DateTime.

System_CAPS_pubmethodGetMonthsInYear(Int32)

Returns the number of months in the specified year in the current era.

System_CAPS_pubmethodGetMonthsInYear(Int32, Int32)

When overridden in a derived class, returns the number of months in the specified year in the specified era.

System_CAPS_pubmethodGetSecond(DateTime)

Returns the seconds value in the specified DateTime.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek)

Returns the week of the year that includes the date in the specified DateTime value.

System_CAPS_pubmethodGetYear(DateTime)

When overridden in a derived class, returns the year in the specified DateTime.

System_CAPS_pubmethodIsLeapDay(Int32, Int32, Int32)

Determines whether the specified date in the current era is a leap day.

System_CAPS_pubmethodIsLeapDay(Int32, Int32, Int32, Int32)

When overridden in a derived class, determines whether the specified date in the specified era is a leap day.

System_CAPS_pubmethodIsLeapMonth(Int32, Int32)

Determines whether the specified month in the specified year in the current era is a leap month.

System_CAPS_pubmethodIsLeapMonth(Int32, Int32, Int32)

When overridden in a derived class, determines whether the specified month in the specified year in the specified era is a leap month.

System_CAPS_pubmethodIsLeapYear(Int32)

Determines whether the specified year in the current era is a leap year.

System_CAPS_pubmethodIsLeapYear(Int32, Int32)

When overridden in a derived class, determines whether the specified year in the specified era is a leap year.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticReadOnly(Calendar)

Returns a read-only version of the specified Calendar object.

System_CAPS_pubmethodToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Returns a DateTime that is set to the specified date and time in the current era.

System_CAPS_pubmethodToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

When overridden in a derived class, returns a DateTime that is set to the specified date and time in the specified era.

System_CAPS_pubmethodToFourDigitYear(Int32)

Converts the specified year to a four-digit year by using the TwoDigitYearMax property to determine the appropriate century.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticCurrentEra

Represents the current era of the current calendar.

A calendar divides time into units, such as weeks, months, and years. The number, length, and start of the divisions vary in each calendar.

System_CAPS_noteNote

For information about using the calendar classes in the .NET Framework, see Working with Calendars.

Any moment in time can be represented as a set of numeric values using a particular calendar. For example, a vernal equinox occurred at (1999, 3, 20, 8, 46, 0, 0.0) in the Gregorian calendar, that is, March 20, 1999 C.E. at 8:46:00:0.0. An implementation of Calendar can map any date in the range of a specific calendar to a similar set of numeric values, and DateTime can map such sets of numeric values to a textual representation using information from Calendar and DateTimeFormatInfo. The textual representation can be culture-sensitive, for example, "8:46 AM March 20th 1999 AD" for the en-US culture, or culture-insensitive, for example, "1999-03-20T08:46:00" in ISO 8601 format.

A Calendar implementation can define one or more eras. The Calendar class identifies the eras as enumerated integers, where the current era (CurrentEra) has the value 0.

To make up for the difference between the calendar year and the actual time that the earth rotates around the sun or the actual time that the moon rotates around the earth, a leap year has a different number of days from a standard calendar year. Each Calendar implementation defines leap years differently.

For consistency, the first unit in each interval (the first month, for example) is assigned the value 1.

The System.Globalization namespace includes the following Calendar implementations:

The following code example demonstrates the members of the Calendar class.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft