Share via


Calendar Class

Definition

Manipulates the representation of a DateTime within a given calendar and clock.

public ref class Calendar sealed
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ICalendarFactory2, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ICalendarFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Calendar final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ICalendarFactory2, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.ICalendarFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class Calendar final
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ICalendarFactory2), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ICalendarFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Calendar
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ICalendarFactory2), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.ICalendarFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class Calendar
function Calendar(languages, calendar, clock, timeZoneId)
Public NotInheritable Class Calendar
Inheritance
Object Platform::Object IInspectable Calendar
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

If your app passes language tags used in this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

Language tags support the Unicode extensions "ca-" and "nu-". (See Unicode Key/Type Definitions.) Note that these extensions can affect the calendar used by Calendar objects.

Constructors

Calendar()

Creates a Calendar object and initializes it to the current DateTime.

Calendar(IIterable<String>, String, String, String)

Creates a Calendar object that is initialized with a language list, calendar, clock, and time zone.

Calendar(IIterable<String>, String, String)

Creates a Calendar object that is initialized with a language list, calendar, and clock.

Calendar(IIterable<String>)

Creates a Calendar object that is initialized with a language list.

Properties

Day

Gets or sets the day.

DayOfWeek

Gets the day of the week.

Era

Gets or sets the era.

FirstDayInThisMonth

Gets the first Day of the current Month.

FirstEra

Gets the first Era available in the calendar.

FirstHourInThisPeriod

Gets the first Hour of the current Period.

FirstMinuteInThisHour

Gets the first Minute of the current Hour.

FirstMonthInThisYear

Gets the first Month of the current Year.

FirstPeriodInThisDay

Gets the first Period of the current Day.

FirstSecondInThisMinute

Gets the first Second of the current Minute.

FirstYearInThisEra

Gets the first Year of the current Era.

Hour

Gets or sets the hour.

IsDaylightSavingTime

Gets a Boolean indicating if Daylight Saving Time is in effect for the date of this Calendar object.

Languages

Gets the priority list of language identifiers that is used when formatting components as strings.

LastDayInThisMonth

Gets the last Day of the current Month.

LastEra

Gets the last Era available in the calendar.

LastHourInThisPeriod

Gets the last Hour of the current Period.

LastMinuteInThisHour

Gets the last Minute of the current Hour.

LastMonthInThisYear

Gets the last Month of the current Year.

LastPeriodInThisDay

Gets the last Period of the current Day.

LastSecondInThisMinute

Gets the last Second of the current Minute.

LastYearInThisEra

Gets the last Year of the current Era.

Minute

Gets or sets the minute.

Month

Gets or sets the month.

Nanosecond

Gets or sets the nanosecond.

NumberOfDaysInThisMonth

Gets the number of days in the current month of this Calendar object.

NumberOfEras

Gets the number of eras in this Calendar object.

NumberOfHoursInThisPeriod

Gets the number of hours in the current day period of this Calendar object.

NumberOfMinutesInThisHour

Gets the number of Minutes in the current Hour.

NumberOfMonthsInThisYear

Gets the number of months in the current year of this Calendar object.

NumberOfPeriodsInThisDay

Gets the number of periods in the current day of this Calendar object.

NumberOfSecondsInThisMinute

Gets the number of Seconds in the current Minute.

NumberOfYearsInThisEra

Gets the number of years in the current era of this Calendar object.

NumeralSystem

Gets or sets the numbering system that is used when formatting components as strings.

Period

Gets or sets the period of the current day.

ResolvedLanguage

Gets the language that was most recently used to perform calendar formatting or operations.

Second

Gets or sets the second.

Year

Gets or sets the year.

Methods

AddDays(Int32)

Increments or decrements the day.

AddEras(Int32)

Increments or decrements the era.

AddHours(Int32)

Increments or decrements the hour.

AddMinutes(Int32)

Increments or decrements the minute.

AddMonths(Int32)

Increments or decrements the month.

AddNanoseconds(Int32)

Increments or decrements the nanosecond.

AddPeriods(Int32)

Increments or decrements the period.

AddSeconds(Int32)

Increments or decrements the second.

AddWeeks(Int32)

Increments or decrements the day by the specified number of weeks.

AddYears(Int32)

Increments or decrements the year.

ChangeCalendarSystem(String)

Sets a new calendar system to be used by this Calendar object.

ChangeClock(String)

Sets a new clock to be used by this Calendar object.

ChangeTimeZone(String)

Sets a new time zone to be used by this Calendar object.

Clone()

Creates a copy of the Calendar object.

Compare(Calendar)

Compares this calendar to another Calendar object and indicates whether the DateTime of one is earlier, equal to, or later than that of the other.

CompareDateTime(DateTime)

Compares this calendar to a DateTime object and indicates whether the date and time of one is earlier, equal to, or later than that of the other.

CopyTo(Calendar)

Copies the values from another Calendar object into this Calendar.

DayAsPaddedString(Int32)

Returns a string representation of the day, optionally zero-padded.

DayAsString()

Returns a string that contains the numeric representation of the day.

DayOfWeekAsSoloString()

Returns a string representation of the day of the week suitable for stand-alone display.

DayOfWeekAsSoloString(Int32)

Returns a string representation of the day of the week suitable for stand-alone display.

DayOfWeekAsString()

Returns a string representation of the day of the week suitable for inclusion with other date components.

DayOfWeekAsString(Int32)

Returns a string representation of the day of the week suitable for inclusion with other date components.

EraAsString()

Returns a string representation of the era.

EraAsString(Int32)

Returns a string representation of the era. The string chosen is closest in length to the ideal length.

GetCalendarSystem()

Gets the calendar system that is used by this Calendar object.

GetClock()

Gets the clock that is used by this Calendar object.

GetDateTime()

Builds a date and time, given the components of this Calendar object.

GetTimeZone()

Gets the identifier that identifies the time zone that is used by this Calendar object.

HourAsPaddedString(Int32)

Returns a string representation of the hour, optionally zero-padded.

HourAsString()

Returns a string that contains the numeric representation of the hour.

MinuteAsPaddedString(Int32)

Returns a string representation of the minute, optionally zero-padded.

MinuteAsString()

Returns a string that contains the numeric representation of the minute.

MonthAsNumericString()

Returns a string that contains the numeric representation of the month.

MonthAsPaddedNumericString(Int32)

Returns a string representation of the month, optionally zero-padded.

MonthAsSoloString()

Returns a string representation of the month suitable for stand-alone display.

MonthAsSoloString(Int32)

Returns a string representation of the month suitable for stand-alone display.

MonthAsString()

Returns a string representation of the month suitable for inclusion with other date components.

MonthAsString(Int32)

Returns a string representation of the month suitable for inclusion with other date components.

NanosecondAsPaddedString(Int32)

Returns a string representation of the nanosecond, optionally zero-padded.

NanosecondAsString()

Returns a string that contains the numeric representation of the nanosecond.

PeriodAsString()

Returns a string representation of the day period, such as AM or PM, that uses the most common abbreviation available.

PeriodAsString(Int32)

Returns a string representation of the day period, such as AM or PM.

SecondAsPaddedString(Int32)

Returns a string representation of the second, optionally zero-padded.

SecondAsString()

Returns a string that contains the numeric representation of the second.

SetDateTime(DateTime)

Sets all the date and time fields to the date and time represented by the DateTime parameter.

SetToMax()

Sets the components of this Calendar object to the latest DateTime supported.

SetToMin()

Sets the components of this Calendar object to the earliest DateTime supported.

SetToNow()

Sets the components of this Calendar object to the current DateTime.

TimeZoneAsString()

Returns the full time zone name applicable at the instant of time that this Calendar object represents.

TimeZoneAsString(Int32)

Returns the abbreviated time zone name applicable at the instant of time that this Calendar object represents.

YearAsPaddedString(Int32)

Returns a string representation of the year, optionally zero-padded.

YearAsString()

Returns a string representation of the year without any initial zero padding.

YearAsTruncatedString(Int32)

Returns a string representation of the year, optionally truncated.

Applies to

See also