CivilDate
(and its siblings) represents a date and time corresponding to the requirements of ISO-8601.
This means specifically that it uses the proleptic Gregorian calendar whose days are 24 hours long and begin and end at midnight.
The constructor may only be called as such. It takes 3 numeric arguments.
year
the Gregorian yearmonth
the Gregorian monthday
the Gregorian day of the month
fromZonedDateTime
creates a new CivilDate
object by calculating its values based of the
ZonedDateTime
passed in.
The .year
property represents the year of the CivilDate
.
The .month
property represents the month of the CivilDate
.
The .day
property represents the day of the month of the CivilDate
.
The .dayOfWeek
property represents the day of the week where Monday is 1
and Sunday
is 7
in accordance with ISO-8601.
The .dayOfYear
property represents the ordinal day of the Gregorian year according to ISO-8601.
The .weekOfYear
property represents the ISO week-number. Beware that dates at the begining of a
year may be part of a week from the preceding year, and dates at the end of a year may be part of
a week at the beginning of the next year, as the first week of any year is defined as the week that
contains the first Thursday of the week.
Creates a new CivilDate
object by adding (subtracting for negative values) values to its members.
The specified values must be numeric if specified.
The algorithm is such that:
- the individual values are added to the existing values.
- the range of
days
is ensured to be between 1 and 29-31 depending on the month by adjustingmonth
- the range of
months
is ensured to be between 1 and 12 by adjusting theyears
.
Creates a new CivilDate
object by overriding specified values to its members.
The specified values must be numeric if specified.
Combines this CivilDate
with the passed CivilTime
to create a new CivilDateTime
object.
Equivalent to date.toDateString()
Equivalent to date.toString()
.toDateString()
creates an ISO-8601 compliant string in the format:
year
-month
-day
.
The year
is 0-padded to a minimum of 4 digits. month
and day
.
.toWeekDateString()
creates an ISO-8601 compliant string in the format:
year
-Wweek
-weekday
.
The year
is 0-padded to a minimum of 4 digits. week
is 0-padded to a minimum of 2 digits.
The week
is the ISO week as calculated by .weekOfYear
and the weekday
is the ISO week-day as
calculated by .dayOfWeek
. The year
may be one year before/after the .year
property of the
CivilDate
if the specified date is part of the last week of the previous year or the first
week of the following year.
.toOrdinalDateString()
creates an ISO-8601 compliant strung in the format:
year
-day-of-year
.
The year
is 0-padded to a minimum of 4 digits. dof-of-year
is 0-padded to a minimum of 3 digits.
The day-of-year
is the ordinal day as calculated by .dayOfYear
.
Creates a new CivilDate
by parsing an ISO-8601 string in the format created by .toDateString()
.
Creates a new CivilDate
by parsing an ISO-8601 string in the format created by .toWeekDateString()
.
Creates a new CivilDate
by parsing an ISO-8601 string in the format created by .toOrdinalDateString()
.
Creates a new CivilDate
by parsing an ISO-8601 string in the one of the formats created .toDateString()
, .toWeekDateString()
or .toOrdinalDateString()
.