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

Simple date in spanish not working: "Agosto 23" #201

Open
acrodrig opened this issue Jun 7, 2017 · 9 comments
Open

Simple date in spanish not working: "Agosto 23" #201

acrodrig opened this issue Jun 7, 2017 · 9 comments

Comments

@acrodrig
Copy link

acrodrig commented Jun 7, 2017

The following program:

const chrono = require("chrono-node");
console.log(chrono.parse("Agosto 23"));
console.log(chrono.parse("August 23"));

Outputs:

[]
[ ParsedResult {
    ref: 2017-06-07T00:32:53.896Z,
    index: 0,
    text: 'August 23',
    tags: { ENMonthNameMiddleEndianParser: true },
    start: ParsedComponents { knownValues: [Object], impliedValues: [Object] } } ]

The second (english date) was parsed correctly, but the exact translation does not work.

Can you help?

@wanasit
Copy link
Owner

wanasit commented Jun 17, 2017

I don't speak Spanish, but look like Spanish date format is "little-endian". It should be "23 Agosto", not "August 23" like US English.

I guess that why @gimenete, the contributor, didn't add the middle-endian parser for Spanish.

@gimenete
Copy link
Contributor

That's right. In Spanish you say "23 Agosto", but never "Agosto 23"

@acrodrig
Copy link
Author

I beg to differ. There are a lot of circumstances where this date pattern Is useful. Even if it is true that the date first/month second is more common I do not see any downside in chrono recognizing it.

@gimenete
Copy link
Contributor

The idea is to avoid false positives such as "He trabajado en agosto 23 días" (I've worked in August for 23 days)

@acrodrig
Copy link
Author

@gimenete this is hitting us on a production software. If a user responds "Agosto 23" without any other words around, I do not think there are any false positives. Maybe we can have a strict flag? Or I can fork if you point me to the right field where to fix this. Thanks.

@gimenete
Copy link
Contributor

@acrodrig I like the idea of an strict flag. Nevertheless I'm not a maintainer of this project. I made a few contributions and I give my opinion in a few issues, but that's all. You can make a PR if you want, instead of forking it.

@benaubin
Copy link
Collaborator

Doesn't Chrono already have a strict mode (instead of casual config). Might be mistaken, but I think we have something like it.

@wanasit
Copy link
Owner

wanasit commented Aug 20, 2017

@acrodrig For your use case, you can create the middle-endian as a custom parser for ES (see. how the little-endian parser work).

However, it would be nicer if you can implement the parser behind casual mode and submit make a PR. I don't have much time recently, but I think we can help reviewing the change.

@acrodrig
Copy link
Author

Thanks @wanasit. I will do that.

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

No branches or pull requests

4 participants