mckamey / countdownjs

A simple JavaScript API for producing an accurate, intuitive description of the timespan between two Date instances.
http://countdownjs.org
MIT License
497 stars 95 forks source link

[feature] for better and easier reading convert weeks into month without some hours and minutes #24

Open AngelTs opened 7 years ago

AngelTs commented 7 years ago

2017-09-25 15:55:00 to 2017-08-25 17:12:00 is: 4 weeks, 1 day, 22 hours, 43 minutes and 51 seconds but should be much better if be: 1 month without 1 hour and 17 minutes (and 9 seconds) http://countdownjs.org/demo.html

andyklimczak commented 7 years ago

Are you expecting 4 weeks, 2 days?

other datetime difference calculator => Result: 30 days, 22 hours, 43 minutes and 0 seconds

mckamey commented 7 years ago

4 weeks is only equal to a month in February and even then only approximately 3/4 of the time (leap years are 29 days).

In other words, 4 weeks is wrong nearly ~94% of the time.

AngelTs commented 7 years ago

Guys, you are right, but my point was something different. My apologies that i didn't write correct description first time. Sorry

mckamey commented 7 years ago

The whole point of the API is you get to choose if you want weeks, months, etc. Whatever you want just set those units.

So if weeks is more intuitive for you then use weeks. Or if months is more intuitive then use months.

But don't expect 4 weeks to be 1 month because that is only true less than 4% of the time. The API will give you units you want but it won't fudge the number just because you think about things incorrectly most of the time.

If you have another point, then I'm not understanding what it is.

AngelTs commented 7 years ago

Is it possible with API to convert 4 weeks, 1 day, 22 hours, 43 minutes and 51 seconds to 1 month without 1 hour and 17 minutes (and 9 seconds) ?

mckamey commented 7 years ago

I'll try to answer this one more time:

You can choose any units you want but it won't give you a wrong answer just because you don't understand how time works.

So you can pick just get months without weeks, days, hours, minutes, etc. Look at the readme to see how to pick the units.

But if you have less than one month (e.g., 4 weeks is less than one month ~94% of the time) then it is NOT going to tell you 1 month.

AngelTs commented 7 years ago

mckamey, I understand you and wrote above that you are right (no need to repeat your answer). Also wrote that I have made mistake with my first description- which you clearly didn't read. I simple suggest a new feature, because at the end of the day we want countdown.js to be better right? So I asked and answer (by myself) on my above question: No, present version of countdown.js can't convert "4 weeks, 1 day, 22 hours, 43 minutes and 51 seconds" to "1 month without 1 hour and 17 minutes"

mckamey commented 7 years ago

I've read every one of these but I am so confused as to what you are asking for. What would be this feature you are suggesting? How does it work? And how would it make countdown.js better?

What do you propose the math would be to convert "4 weeks, 1 day, 22 hours, 43 minutes and 51 seconds" to "1 month without 1 hour and 17 minutes"?

Drop weeks as a unit. You'd get 29 days (and change). 29 days is equal to a month in February on leap years. That is correct, what, 2% of the time?

If it was one day more (30) then you'd have better odds. 30 days is the correct length for 1/3 of the months.

If you want to just have months as a unit, you can do that. If you want fractional units, you can do that.

If you want an arbitrary amount of time to magically equal a month, then no, you can't do that with this library (or I suspect any others you will find).