from Monday - Thursday, I get the right days, but from Friday, I get the wrong days. Why?
Code example:
Text(DateFormat('EEEE').format(DateTime(DateTime.friday))),
And i get Saturday. Is that a bug?
from Monday - Thursday, I get the right days, but from Friday, I get the wrong days. Why?
Code example:
Text(DateFormat('EEEE').format(DateTime(DateTime.friday))),
And i get Saturday. Is that a bug?
It's not a bug,
DateTime()
default constructor takesyear
as the first argument:So this code:
Is essentially constructing a
DateTime
of the year 5, becauseDateTime.friday
is nothing more than aconst int
that equals to 5:Formatting with
DateFormat
returns Saturday which happens to be the first day of the year:DateTime
should be used to define a specific Date and Time, for example, Friday 11th Dec 2020, it can't be used to define any Friday.