Partly negative period between 2 dates with NodaTime

Viewed 319

I use NodaTime library to get period between two days, but sometimes I get partly negative period between two dates:

var start = DateTime.Now;
var end = start.AddDays(7).AddMinutes(-1);

//6 days, 24 hours and -1 minutes
var period = Period.Between(LocalDateTime.FromDateTime(start), LocalDateTime.FromDateTime(end));

How can I prevent such behavior? At this moment I already have found one solution:

//6 days, 23 hours and 59 minutes, but no weeks, months, years
var duration = period.ToDuration();

But duration object is not contrain weeks, months, years and so on.

2 Answers
Related