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

The dehumanize method doesn't recognize singular nouns #1150

Open
God-damnit-all opened this issue Mar 13, 2023 · 5 comments
Open

The dehumanize method doesn't recognize singular nouns #1150

God-damnit-all opened this issue Mar 13, 2023 · 5 comments
Labels

Comments

@God-damnit-all
Copy link

arrow.now().dehumanize("1 day ago").isoformat() doesn't work.

arrow.now().dehumanize("1 days ago").isoformat() does work.

Same with week, month, and year.

@krisfremen
Copy link
Member

Looking at it, it seems like the dehumanize only supports the plurals.

@anishnya any insight on this one?

@anishnya
Copy link
Member

We use the humanize output and reverse it for dehumanize.

arrow.now().dehumanize("a day ago").isoformat() will work since that's what humanize produces. Humanize doesn't ever produce the "1 days ago" output, hence we don't have that mapping in there.

We certainly could add this translation in for English, but ideally we would want similar mappings across all languages. I'm open to making this a broader issue and attempting to solve it.

@ben-kenney
Copy link

I came here looking for a solution to this issue.

arrow.now().dehumanize("1 hour ago").isoformat() throws the following error:

ValueError: Input string not valid. Note: Some locales do not support the week granularity in Arrow. If you are attempting to use the week granularity on an unsupported locale, this could be the cause of this error.

whereas arrow.now().dehumanize("1 hours ago").isoformat() does work but the plural hours doesn't make grammatical sense in this case.

@davidgolden
Copy link

@anishnya As @ben-kenney points out, your comment doesn't address the issue. While I can understand that 1 days ago might not be valid, 1 day ago should be, but the latter throws a ValueError.

@God-damnit-all
Copy link
Author

Yeah, it's worth pointing out again that dehumanize implies that the string is already humanized, but it's hard to say "1 days ago" is considered humanized.

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

5 participants