Year class
A convenient class to work with only iso year
Constructors
- Year(int year)
-
Constructs the Year object
const
- Year.fromDate(Date date)
-
Create Year from Date
factory
- Year.fromDateTime(DateTime datetime)
-
////////////////////////////////// FACTORIES
Create Year from DateTime
factory
- Year.lastYear()
-
Get last year
factory
- Year.nextYear()
-
Get next year
factory
- Year.now()
-
Get the current year
factory
- Year.thisYear()
-
Same as Year.now
factory
Properties
- april → Month
-
Returns april
no setter
- august → Month
-
Returns august
no setter
-
dates
→ Map<
int, Date> -
Returns the dates of the year
no setter
- december → Month
-
Returns december
no setter
- endOfYear → Date
-
Get the date for the end of year
no setter
- february → Month
-
Returns february
no setter
- firstISOWeek → Week
-
Get the first ISO week of the year
no setter
- firstWeek → Week
-
Get the first week of the year
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isLastYear → bool
-
Return true if year is last year
no setter
- isNextYear → bool
-
Return true if year is next year
no setter
-
isoWeeks
→ Map<
int, Week> -
Returns the iso weeks of the year (week starting monday)
no setter
- isThisYear → bool
-
Return true if year is this year
no setter
- january → Month
-
Returns january
no setter
- july → Month
-
Returns july
no setter
- june → Month
-
Returns june
no setter
- key → String
-
/////////////////////////////// KEY
Convert Year to a unique id
no setter
- lastISOWeek → Week
-
Get the last week of the year
no setter
- lastWeek → Week
-
Get the last week of the year
no setter
- march → Month
-
Returns march
no setter
- may → Month
-
Returns may
no setter
-
months
→ Map<
MONTH, Month> -
Returns the months of the year
no setter
- november → Month
-
Returns november
no setter
- october → Month
-
Returns october
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- september → Month
-
Returns september
no setter
- startOfYear → Date
-
/////////////////////////////// GETTERS
Get the date for the start of year
no setter
-
weeks
→ Map<
int, Week> -
Returns the weeks of the year (week starting sunday)
no setter
- year → int
-
A number that represent year
final
Methods
-
add(
Duration duration) → Year - ////////////////////////////////// OPERATIONS Add a Duration to this week
-
addDays(
int amount) → Year - Add a certain amount of days to the end of the year
-
addMonths(
int amount) → Year - Add a certain amount of months to the end of the year
-
addQuarters(
int amount) → Year - Add a certain amount of quarters to the end of the year
-
addWeeks(
int amount) → Year - Add a certain amount of weeks to the end of the year
-
addYears(
int amount) → Year - Add a certain amount of years to the end of the year
-
copyWith(
{int? year}) → Year - ////////////////////////////////// SETTERS Create a new copy with updated values
-
format(
[String? pattern, String? locale]) → String - Short-hand to DateFormat
-
isAfter(
Year other) → bool -
////////////////////////////////// COMPARISON
Return true if year is after
other
, false otherwise. -
isBefore(
Year other) → bool -
Return true if year is before
other
, false otherwise. -
isSameOrAfter(
Year other) → bool -
Return true if other
isEqual
or isAfter to this date -
isSameOrBefore(
Year other) → bool -
Return true if other
isEqual
or isBefore to this date -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setYear(
int year) → Year - Set the year
-
subDays(
int amount) → Year - Subtracts an amount of days from the start of year
-
subMonths(
int amount) → Year - Subtracts an amount of months from the start of year
-
subQuarters(
int amount) → Year - Subtracts an amount of quarters from the start of year
-
subtract(
Duration duration) → Year - Subtract a Duration to this week
-
subWeeks(
int amount) → Year - Subtracts an amount of weeks from the start of year
-
subYears(
int amount) → Year - Subtracts an amount of years from this year.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator <(
Year other) → bool - Less than operator
-
operator <=(
Year other) → bool - Less than or equals to operator
-
operator ==(
Object other) → bool -
////////////////////////////////// OBJECT OVERRIDES
override
-
operator >(
Year other) → bool - Greater than operator
-
operator >=(
Year other) → bool - Greater or equals to operator
Static Methods
-
fromKey(
String key) → Year? - Convert a unique id to Year
-
parse(
String dateStr, {String? format, bool utc = false}) → Year -
////////////////////////////////// FORMAT
Constructs a new DateTime instance based on
dateStr
. -
tryParse(
String dateStr, {String? format, bool utc = false}) → Year? -
Constructs a new DateTime instance based on
dateStr
.
Constants
- endOfTime → const Year
- Const value to signify the end of time that can be used as a default value
- epoch → const Year
- ////////////////////////////////// CONST Const value for the year of epoch that can be used as a default value
- startOfTime → const Year
- Const value for year 1 that can be used as a default value