Servoy / svyUtils

Wide range of low-level utility methods and application concepts for Servoy solutions
5 stars 5 forks source link

function getDateDifference(start, end) #21

Closed jmlpinaEtec closed 6 years ago

jmlpinaEtec commented 6 years ago

I am using this function to get difference days between two date. But when inside these days is the last sunday of March, there are 36E5 less seconds, so doesn´t count this day. Is there a solution for that?. Thanks in Advance

pruhsert commented 6 years ago

Could you show exactly with what dates you are calling the function, what exactly you get and what you expect to get?

jmlpinaEtec commented 6 years ago

Hi Patrick

getDateDifference('24.03.2018', '25.03.2018').days = 1
getDateDifference('25.03.2018', '26.03.2018').days = 0
getDateDifference('26.03.2018', '27.03.2018').days = 1
getDateDifference('27.03.2018', '28.03.2018').days = 1

The problem is the time shift from winter to summer. The less hour on 25.03.2016 give 8.28 E7 milliseconds thats is true, but when divide by (1000x60x60x24) result 0 days and 23 hours

Thanks

pruhsert commented 6 years ago

Just to be sure what we are talking about. This

scopes.svyDateUtils.getDateDifference(new Date(2018,2,25), new Date(2018,2,26))

gives me

{difference:8.28E7,days:0.0,hours:23.0,minutes:0.0,seconds:0.0}

Are you saying it should return days:1, hours:0, minutes:0 and seconds:0?

I think the result is correct because you are really loosing one hour...

Woody-Soft commented 6 years ago

But you’re not asking about hours, you are asking for days. And regardless how many hours that day has, it should be still 1 day. wOOdy

pruhsert commented 6 years ago

Not sure I agree. You are asking for the time difference of two given instances in time expressed in days, hours, minutes and seconds. And between these two dates there is no full day (24 hours) difference.

The scope has another function getDayDifference that will return 1 (day) here.

Woody-Soft commented 6 years ago

Hmm, yes you’re correct. (as always ☺ ) Using GetDayDifference() ist he correct function if one is interested in pure day numbers.

wOOdy

pruhsert commented 6 years ago

If we all agree on that, we can close this issue?

jmlpinaEtec commented 6 years ago

Ok I saw the function getDayDifference() but I thought it's similar to getDateDifference().days .

I will use getDayDifference();

Ok we can close this issue.

Thanks a lot