A date without a time-zone in the ISO-8601 calendar system, such as 2010-08-05.

LocalDate is an immutable object that represents a date, often viewed as year-month-day. For example, the value “1st October 2014” can be stored in a LocalDate.

This class does not store or represent a time or time-zone. Instead, it is a description of the date, as used for birthdays. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.

Note that this type can represent dates in the range [-5877641-06-23; 5881580-07-17] while the ES5 date type can only represent values in the range of [-271821-04-20; 275760-09-13]. In the event that year, month, day parameters do not fall within the ES5 date range an Error will be thrown. If you wish to represent a date outside of this range, pass a single parameter indicating the days since epoch. For example, -1 represents 1969-12-31.

Members

_value

If date cannot be represented yet given a valid days since epoch, track it internally.

Number

day

A number between 1 and the number of days in the given month of the given year (28, 29, 30, 31). May return NaN if cannot be represented as a Date.

Number

month

A number between 1 and 12 inclusive representing the month. May return NaN if cannot be represented as a Date.

Number

year

A number representing the year. May return NaN if cannot be represented as a Date.

Constructor

new

LocalDate

(Number year, Number month, Number day)

Creates a new instance of LocalDate.

Parameters:
Name Type Description
year Number

The year or days since epoch. If days since epoch, month and day should not be provided.

month Number

Between 1 and 12 inclusive.

day Number

Between 1 and the number of days in the given month of the given year.

Methods

compare

(LocalDate other)

Compares this LocalDate with the given one.

Parameters:
Name Type Description
other LocalDate

date to compare against.

Returns:
Type Description
number

0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.

equals

(LocalDate other)

Returns true if the value of the LocalDate instance and other are the same

Parameters:
Name Type Description
other LocalDate
Returns:
Type Description
Boolean

LocalDate.fromBuffer

(Buffer buffer)

Creates a new instance of LocalDate using the bytes representation.

Static
This function is static
Parameters:
Name Type Description
buffer Buffer

LocalDate.fromDate

(Date date)

Creates a new instance of LocalDate using the year, month and day from the provided local date time.

Static
This function is static
Parameters:
Name Type Description
date Date

LocalDate.fromString

(String value)

Creates a new instance of LocalDate using the year, month and day provided in the form: yyyy-mm-dd or days since epoch (i.e. -1 for Dec 31, 1969).

Static
This function is static
Parameters:
Name Type Description
value String

LocalDate.now

()

Creates a new instance of LocalDate using the current year, month and day from the system clock in the default time-zone.

Static
This function is static

toBuffer

()

Gets the bytes representation of the instance.

Returns:
Type Description
Buffer

toJSON

()

Gets the string representation of the instance in the form: yyyy-mm-dd, valid for JSON.

Returns:
Type Description
String

toString

()

Gets the string representation of the instance in the form: yyyy-mm-dd if the value can be parsed as a Date, otherwise days since epoch.

Returns:
Type Description
String

LocalDate.utcNow

()

Creates a new instance of LocalDate using the current date from the system clock at UTC.

Static
This function is static