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

Colloquial report wrong "just now" when gap between dates are expressed in minutes and the left comparing date is future #359

Closed
timefrancesco opened this issue Dec 11, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@timefrancesco
Copy link

timefrancesco commented Dec 11, 2016

Hey there, I believe there are still a couple of issues in Colloquial and ColloquialSinceNow.
Given the following code:

let future = Date().add(components: 8.minutes)
let futureStringOne = try future.colloquialSinceNow().colloquial
let futureStringTwo = try Date().colloquial(to: future,  max: 1 ).colloquial
  • futureStringOne outputs just now
  • futureStringTwo outputs 8 minutes ago.
    I would expect both string to be in 8 minutes.

Also, all the parameters passed in colloquialSinceNow are ignored, it will always return the same string no matter what other parameters I pass in the function.

I'm using version 4.0.8.
Thanks

@timefrancesco
Copy link
Author

I realized I might have called colloquial with inverted date, but when calling it this way:

let futureStringTwo = try future.colloquial(to: Date(), max: 1 ).colloquial

it also returns just now.
I can't find a way to write future dates if the interval is less than 1 hour.

@malcommac
Copy link
Owner

Hi,
Okay that's clearly a bug; when gap between two dates is expressed in minutes the value in your example is -8 and -8 < 5 minutes, so it's wrong perceived in "just now" case.
I've solved it in this commit 88067f1. You will found it in 4.0.9 upcoming release.
Thank you

@malcommac malcommac added this to the 4.0.9 milestone Dec 19, 2016
@malcommac malcommac added the bug label Dec 19, 2016
@malcommac malcommac self-assigned this Dec 19, 2016
@malcommac malcommac changed the title Colloquial & ColloquialSinceNow issues Colloquial report wrong "just now" when gap between dates are expressed in minutes and the left comparing date is future Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants