docs.rodeo

MDN Web Docs mirror

Temporal.PlainDate

{{JSRef}} {{SeeCompatTable}} 

The Temporal.PlainDate object represents a calendar date (a date without a time or time zone); for example, an event on a calendar which happens during the whole day no matter which time zone it’s happening in. It is fundamentally represented as an ISO 8601 calendar date, with year, month, and day fields, and an associated calendar system.

Description

A PlainDate is essentially the date part of a {{jsxref("Temporal.PlainDateTime")}}  object, with the time information removed. Because the date and time information don’t have much interaction, all general information about date properties is documented here.

RFC 9557 format

PlainDate objects can be serialized and parsed using the RFC 9557 format, an extension to the ISO 8601 / RFC 3339 format. The string has the following form (spaces are only for readability and should not be present in the actual string):

YYYY-MM-DD [u-ca=calendar_id]

As an input, you may optionally include the time, offset, and time zone identifier, in the same format as PlainDateTime, but they will be ignored. Other annotations in the [key=value] format are also ignored, and they must not have the critical flag.

When serializing, you can configure whether to display the calendar ID, and whether to add a critical flag for it.

Invalid date clamping

The {{jsxref("Temporal/PlainDate/from", "Temporal.PlainDate.from()")}} , {{jsxref("Temporal/PlainDate/with", "Temporal.PlainDate.prototype.with()")}} , {{jsxref("Temporal/PlainDate/add", "Temporal.PlainDate.prototype.add()")}} , {{jsxref("Temporal/PlainDate/subtract", "Temporal.PlainDate.prototype.subtract()")}}  methods, and their counterparts in other Temporal objects, allow constructing dates using calendar-specific properties. The date components may be out of range. In the ISO calendar, this is always an overflow, such as the month being greater than 12 or the day being greater than the number of days, and fixing it would only involve clamping the value to the maximum allowed value. In other calendars, the invalid case may be more complex. When using the overflow: "constrain" option, invalid dates are fixed to a valid one in the following way:

Constructor

Static methods

Instance properties

These properties are defined on Temporal.PlainDate.prototype and shared by all Temporal.PlainDate instances.

Instance methods

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN