Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Calendar class

Manipulates the representation of a date and time within a given calendar and clock.

Syntax


var calendar = new Windows.Globalization.Calendar(iIterable(String));
var calendar = new Windows.Globalization.Calendar(iIterable(String));
var calendar = new Windows.Globalization.Calendar(iIterable(String));
var calendar = new Windows.Globalization.Calendar();

Members

The Calendar class has these types of members:

Constructors

The Calendar class has these constructors.

ConstructorDescription
Calendar Creates a Calendar object and initializes it to the current date and time.
Calendar(IIterable(String)) Creates a Calendar object that is initialized with a language list.
Calendar(IIterable(String),String,String) Creates a Calendar object that is initialized with a language list, calendar, and clock.
Calendar(IIterable(String),String,String,String) Creates a Calendar object that is initialized with a language list, calendar, clock, and time zone.

 

Methods

The Calendar class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
AddDays Increments or decrements the day.
AddEras Increments or decrements the era.
AddHours Increments or decrements the hour.
AddMinutes Increments or decrements the minute.
AddMonths Increments or decrements the month.
AddNanoseconds Increments or decrements the nanosecond.
AddPeriods Increments or decrements the period.
AddSeconds Increments or decrements the second.
AddWeeks Increments or decrements the day by the specified number of weeks.
AddYears Increments or decrements the year.
ChangeCalendarSystem Sets a new calendar system to be used by this Calendar object.
ChangeClock Sets a new clock to be used by this Calendar object.
ChangeTimeZone Sets a new time zone to be used by this Calendar object.
Clone Creates a copy of the Calendar object.
Compare Compares this calendar to another Calendar object and indicates whether the date and time of one is earlier, equal to, or later than that of the other.
CompareDateTime 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 Copies the values from another Calendar object into this Calendar.
DayAsPaddedString 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 Returns a string representation of the hour, optionally zero-padded.
HourAsString Returns a string that contains the numeric representation of the hour.
MinuteAsPaddedString 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 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 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 Returns a string representation of the second, optionally zero-padded.
SecondAsString Returns a string that contains the numeric representation of the second.
SetDateTime 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 date and time that are supported.
SetToMin Sets the components of this Calendar object to the earliest date and time that are supported.
SetToNow Sets the components of this Calendar object to the current date and time.
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 Returns a string representation of the year, optionally zero-padded.
YearAsString Returns a string representation of the year without any initial zero padding.
YearAsTruncatedString Returns a string representation of the year, optionally truncated.

 

Properties

The Calendar class has these properties.

PropertyAccess typeDescription

Day

Read/write

Gets or sets the day.

DayOfWeek

Read-only

Gets the day of the week.

Era

Read/write

Gets or sets the era.

FirstDayInThisMonth

Read-only

Gets the first Day of the current Month.

FirstEra

Read-only

Gets the first Era available in the calendar.

FirstHourInThisPeriod

Read-only

Gets the first Hour of the current Period.

FirstMinuteInThisHour

Read-only

Gets the first Minute of the current Hour.

FirstMonthInThisYear

Read-only

Gets the first Month of the current Year.

FirstPeriodInThisDay

Read-only

Gets the first Period of the current Day.

FirstSecondInThisMinute

Read-only

Gets the first Second of the current Minute.

FirstYearInThisEra

Read-only

Gets the first Year of the current Era.

Hour

Read/write

Gets or sets the hour.

IsDaylightSavingTime

Read-only

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

Languages

Read-only

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

LastDayInThisMonth

Read-only

Gets the last Day of the current Month.

LastEra

Read-only

Gets the last Era available in the calendar.

LastHourInThisPeriod

Read-only

Gets the last Hour of the current Period.

LastMinuteInThisHour

Read-only

Gets the last Minute of the current Hour.

LastMonthInThisYear

Read-only

Gets the last Month of the current Year.

LastPeriodInThisDay

Read-only

Gets the last Period of the current Day.

LastSecondInThisMinute

Read-only

Gets the last Second of the current Minute.

LastYearInThisEra

Read-only

Gets the last Year of the current Era.

Minute

Read/write

Gets or sets the minute.

Month

Read/write

Gets or sets the month.

Nanosecond

Read/write

Gets or sets the nanosecond.

NumberOfDaysInThisMonth

Read-only

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

NumberOfEras

Read-only

Gets the number of eras in this Calendar object.

NumberOfHoursInThisPeriod

Read-only

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

NumberOfMinutesInThisHour

Read-only

Gets the number of Minutes in the current Hour.

NumberOfMonthsInThisYear

Read-only

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

NumberOfPeriodsInThisDay

Read-only

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

NumberOfSecondsInThisMinute

Read-only

Gets the number of Seconds in the current Minute.

NumberOfYearsInThisEra

Read-only

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

NumeralSystem

Read/write

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

Period

Read/write

Gets or sets the period of the current day.

ResolvedLanguage

Read-only

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

Second

Read/write

Gets or sets the second.

Year

Read/write

Gets or sets the year.

 

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.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Globalization
Windows::Globalization [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Globalization
Windows::Globalization [C++]

Metadata

Windows.winmd

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

See also

Object
Calendar sample (Windows 10)
Globalization preferences sample (Windows 10)

 

 

Show: