[Feature Request] Get only date or only time
JCKodel opened this issue · 8 comments
In C#, we have those two usefull properties of a DateTime:
var now = DateTime.Now; // 2020-04-10T15:27:00
var datePartOnly = now.Date; // 2020-03-10T00:00:00 (returns a DateTime, with 00:00:00 time)
var timePartOnly = now.TimeOfDay; // 15:17:00 (returns a TimeSpan - Duration in Dart)
Is 2020-03-10T00:00:00
2020-04-10T00:00:00
?
Is 15:17:00
15:27:00
?
@JCKodel I add properties. Is it okay with you?
returns a TimeSpan - Duration
The timePartOnly
I added returns a string.
Dart doesn't have TimeSpan.
Hey @shinriyo
Nice work with the PR. I would say, instead of a string from timeOfDay
, maybe a Duration
as a replacement for TimeSpan
.
On second thought, is there really any added benefits in transforming time into a duration?
On second thought, is there really any added benefits in transforming time into a duration?
Yes yes yes!
I'm using this to calculate 12 events with a base date (date of the first event), then adding two days for each event. Every event has an alarm time (so it is easier to calc currentDate + Duration
)
Oh yes, you could definitely do that currentDate + 2.days
is also valid.