Is at same year/month/.../second
Unit comparison cascades. Meaning, if the following is true
this.isAtSameDayAs(other) == true;
these are naturally true.
this.isAtSameMonthAs(other);
this.isAtSameYearAs(other);
Usage
// Local timezone is UTC+8
final DateTime otherBday = DateTime(2003, DateTime.june, 19);
final Moment spiritRoverOnMars = DateTime(2003, DateTime.june, 10).toMoment();
otherBday.isAtSameMonthAs(spiritRoverOnMars); // true
otherBday.isAtSameYearAs(spiritRoverOnMars); // true
List of methods
All extension methods can be called on DateTime and Moment objects.
Setting enforceUTC: true converts both operands to UTC before
checking.
-
isAtSameYearAs() -
isAtSameMonthAs() -
isAtSameDayAs() -
isAtSameHourAs() -
isAtSameMinuteAs() -
isAtSameSecondAs() -
isAtSameMillisecondAs() -
isAtSameMicrosecondAs() -
isSameLocalWeekAs(DateTime other, [int weekStart = DateTime.monday])When called on
DateTimeobjects, weekStart defaults toDateTime.monday.Calling it on
Momentwill determine the start of the week from its localization, therefore omitting the optional argument.