well, if you have the start and end dates (sy/sm/sd, ey/em/ed), then you
can do it directly.

the number of complete years is ey-sy+1 if em>sm or em==sm && ed>=sd, one
less otherwise
(i think this captures the edge conditions correctly)

same for months (irrespective of the number of days in each), and same for
days, simplified since hours, minutes, and seconds are not being used.

you do not need to do a calendrical base conversion (with the issues
Christian shared) now that we realize that you have the start and end
details.

On Fri, Jan 24, 2020 at 9:20 AM Constantine Vassilev <thst...@gmail.com>
wrote:

> I've the start-end date, then how to do that?
>
> On Friday, January 24, 2020 at 9:06:12 AM UTC-8, Constantine Vassilev
> wrote:
>>
>> I have the following task:
>>
>> 1) a number representing days.
>> 2) how to convert it to human readable form?
>>
>> Like this:
>> 11 years 3 months 5 days
>>
>> The actual calculations are:
>>
>> 4095 days = 136.5 months = 11.375 years
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/70cc09a4-0c57-4683-b7b1-de45afcdff6d%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/70cc09a4-0c57-4683-b7b1-de45afcdff6d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 

*Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>*

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQxwGPGq6vkOFCNqANQMt-t3L36hpOLNqW-BtnwGO_ctGg%40mail.gmail.com.

Reply via email to