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

Jiffy difference #57

Closed
rakakhrl opened this issue Mar 18, 2020 · 8 comments
Closed

Jiffy difference #57

rakakhrl opened this issue Mar 18, 2020 · 8 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@rakakhrl
Copy link

Hey jama, i just want to ask one question about the difference method. In the documentation u said that when we look for difference from this

Jiffy({ "year": 2007, "month": 1, "day": 28 }).diff([2017, 1, 29], Units.DAY); // 1

It return 1 day

My question is shouldn't it return 3651 days instead? because its 10 years and 1 day apart

@jama5262
Copy link
Owner

jama5262 commented Mar 18, 2020

Hi, @rakakhrl . I have tried this and it works fine. I tried the following

Jiffy({ "year": 2007, "month": 1, "day": 28 }).diff([2017, 1, 29], Units.DAY) // -3654

and also

Jiffy([2007, 1, 28]).diff([2017, 1, 29], Units.DAY) // -3654

Or maybe I haven't understood your question correctly

@jama5262
Copy link
Owner

jama5262 commented Mar 22, 2020

@rakakhrl I understood your issue. The docs shows the wrong output on the section you have said.

difference

it's supposed to be both to have the same year which is 2017

Jiffy({ "year": 2017, "month": 1, "day": 28 }).diff([2017, 1, 29], Units.DAY); // 1

You could send a PR to fix it if you would like to contribute

@jama5262 jama5262 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Mar 22, 2020
@jaykovski
Copy link

jaykovski commented Mar 29, 2020

Why does this output 0, shouldn't it be 1?
Jiffy({"year": 2020, "month": 3, "day": 29}).diff([2020, 3, 30], Units.DAY)

This is the only day that shows 0, for example this one is correct, outputs 1:
Jiffy({"year": 2020, "month": 3, "day": 28}).diff([2020, 3, 29], Units.DAY)

@jaykovski
Copy link

Also local time now has 1 hour difference

@jama5262
Copy link
Owner

@jaykovski I have tried both
Jiffy({"year": 2020, "month": 3, "day": 29}).diff([2020, 3, 30], Units.DAY)
and
Jiffy({"year": 2020, "month": 3, "day": 28}).diff([2020, 3, 29], Units.DAY)

And they both return correct results which should be -1 not 1 or 0

If you would like to return 1, then just switch them in position, see example below

Jiffy([2020, 3, 30]).diff({"year": 2020, "month": 3, "day": 29}, Units.DAY) // 1

I also tried on local and utc, both return correct results

Or have I not understood your question?

@jaykovski
Copy link

jaykovski commented Mar 29, 2020

The
Jiffy({"year": 2020, "month": 3, "day": 29}).diff([2020, 3, 30], Units.DAY)
returns "0" for me

and

Jiffy({"year": 2020, "month": 3, "day": 28}).diff([2020, 3, 29], Units.DAY)
returns "-1" (which is correct)

@jaykovski
Copy link

Hint: there was a daylight saving time on 29th

@jama5262
Copy link
Owner

jama5262 commented Mar 2, 2021

@jaykovski This may be related to #81, so I will close this issue for now since the docs have been corrected in difference

@jama5262 jama5262 closed this as completed Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants