Created
April 2, 2014 04:53
-
-
Save mattjohnsonpint/9928149 to your computer and use it in GitHub Desktop.
Answer for SO Q22795924
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int days = 678; | |
// First, you need a starting point | |
Instant now = SystemClock.Instance.Now; | |
DateTimeZone timeZone = DateTimeZoneProviders.Bcl.GetSystemDefault(); // or whatever the applicable time zone is | |
LocalDate today = now.InZone(timeZone).Date; | |
// then just add the number of days | |
LocalDate future = today.PlusDays(days); | |
// and obtain a period with the units desired | |
Period period = Period.Between(today, future, PeriodUnits.YearMonthDay); | |
Console.WriteLine("{0} years, {1} months, {2} days", period.Years, period.Months, period.Days); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment