startOf method

Jiffy startOf(
  1. Unit unit
)

Returns a new Jiffy instance representing the start of the specified unit of time

unit must be one of the values in Unit enumeration.

Example:

final jiffy = Jiffy.parse(
  '1997-09-23 13:37:00',
  pattern: 'yyyy-MM-dd HH:mm:ss'
);
final startOfDay = jiffy.startOf(Unit.DAY);
print(startOfDay.format('yyyy-MM-dd HH:mm:ss'));
// output: '1997-09-23 00:00:00'

Implementation

Jiffy startOf(Unit unit) {
  final dateTime =
      _manipulator.startOf(this.dateTime, unit, _locale.startOfWeek());
  return _clone(dateTime);
}