Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FromNow format - incorrect counting #1141

Closed
pasha-zzz opened this issue May 9, 2018 · 12 comments
Closed

FromNow format - incorrect counting #1141

pasha-zzz opened this issue May 9, 2018 · 12 comments

Comments

@pasha-zzz
Copy link

v5.15.4, when date/time (f.e. added) is, f.e. 22:00 1st day and now is 00:20 2nd day - it shows 1d 2h. But only 2h 20min elapsed. Maybe depends from timezone (my is GMT+3)

@antekgla
Copy link
Contributor

Yeah it is a bug...
It is solved in 59c5946
Would be included in the next release.

@pasha-zzz
Copy link
Author

Bug in PeriodBetween function?

@antekgla
Copy link
Contributor

Bug in PeriodBetween function?

I dont know, maybe... technically day is different however it is true what is only 2hs 20min of difference.

@pasha-zzz
Copy link
Author

Maybe check this too "22:00 1st day - 00:20 3rd day"? Must be 1d 2h, not 2d 2h

@pasha-zzz
Copy link
Author

I think this correction:
if HoursBetween(Anow,AThen) < 24 then Days := 0;
we can replace with this:
if CompareTime(Anow,AThen) < 0 then Dec(Days);

@pasha-zzz
Copy link
Author

Additional check needed for other date/time components in PeridBetween. Maybe if Day(Anow)<Day(Athen) - decrease of Month is needed. And same for Month numbers which affect Year

@pasha-zzz
Copy link
Author

default
Period between datetimes - 1 day and 1 second.

@antekgla
Copy link
Contributor

😄

We think the same...

periodbetween

@pasha-zzz
Copy link
Author

pasha-zzz commented May 11, 2018

Tested other components of datetime, only Days are affected. Months and Years are always correct. But PeriodBetween flips values if they are in reversed order. And my final correction for Days is:
if Sign(Anow-Athen)*CompareTime(Anow,Athen) < 0 then Dec(Days);

And for next line I suppose sign correction is preferred too:
DecodeDateTime(Sign(Anow-Athen)*(Anow-AThen),discard,Discard,Discard,Hours,Minutes,Seconds,Discard);

@antekgla
Copy link
Contributor

Thank you for your work in this...
However I can't imagine a case where Athen would be older what Anow, except maybe if you change the clock in your computer to a earlier day/hour.
In every case in real world use Anow would be always older what Athen.

When we call the function

HumanReadableTime(ANow,AThen: TDateTime): string;

the first parameter is the function Now what return the current day/hour so that value would be always older what AThen.

@pasha-zzz
Copy link
Author

Yes, but incorrect datetime possible not only on user side but on the torrents creator side f.e. Additional check not so time consuming I think

antekgla added a commit that referenced this issue May 15, 2018
@antekgla
Copy link
Contributor

Fix (definitely I hope) in c8e84bd
Thanks @pasha-zzz !!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants