I want to get first day of previous month in Dart as DateTime. Below code is working correctly even for x = 1 (passing 0 as month)
print(new DateTime(2016,x-1,1));
but is it by design or I should not relay on it ?
It is by design.
The DateTime
constructor you are using allows overflow and underflow on both days and months. A month value less than one means a month prior to January, which is a month in a previous year. Likewise a day value of less than one is a day in a previous month.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With