Start of year/month/.../second
Usage
// >>> In this example, local timezone is UTC+8 <<<
final Moment tada =
DateTime(2022, 6, 19, 21, 9, 33).toMoment(); // June 19 2022 09:09 PM
tada.startOf(DurationUnit.day); // June 19 2022 12:00 AM
// OR
tada.startOfDay(); // June 19 2022 12:00 AM
List of methods
All extension methods can be called on DateTime and Moment objects.
-
startOf(DurationUnit unit)Methods below are abbreviations for this method.
Special cases:
- Returns clone of the object when passed
DurationUnit.microseconds - Throws
MomentExceptionwhen passedDurationUnit.weekas it doesn't have any way to determine the start of the week.
- Returns clone of the object when passed
-
startOfMillisecond() -
startOfSecond() -
startOfMinute() -
startOfHour() -
startOfDay() -
startOfLocalWeek([int? weekStart])Returns start of the week based on [weekStart]. If it's null, it uses
Moment.defaultLocalization.weekStart. When called onMomentinstance, uses the instance's localization week start -
startOfMonth() -
startOfYear()