How to get the first day of the previous month Datetime with Dartlang

I want to get the first day of the previous month in Dart as a DateTime. Below works , even for x = 1 (transfer 0 per month)

  print(new DateTime(2016,x-1,1));

but is it by design, or shouldn't I relay it?

+4
source share
1 answer

This is by design. The constructor DateTimethat you use allows you to overflow and overflow both days and months. A monthly value of less than one means the month until January, which is the month of the previous year. Similarly, a day value of less than one day is the day in the previous month.

+9
source

Source: https://habr.com/ru/post/1661531/


All Articles