News for hackers. Stuff that matters.
Re:Safari's date-picker is the cause of 1/3 of our customer ... by bradgessler on Tuesday December 27, 2022 @02:39AM (#34146241)
In my web apps, I make dates text boxes that can handle inputs like “next Thursday”, “Monday at 5p”, etc by running the inputs through https://github.com/mojombo/chronic

I like the idea of inputs being able to make sense of as wide of a variety or formats as possible.

For number inputs I’d like to build into Rails something that can handle basic math expressions. For example, a person can enter “120 / 2” in an input and get 60. This is useful for expense apps where you need to expense half of something.

If folks are interested, I can open source these bits. I’d like to expand them as much as possible to handle an even wider variety of inputs.

Re:Safari's date-picker is the cause of 1/3 of our customer ... by mastersummoner on Tuesday December 27, 2022 @02:48AM (#34146293)
Chronic is an awesome date library, agreed.
Re:Safari's date-picker is the cause of 1/3 of our customer ... by bmitc on Tuesday December 27, 2022 @06:57AM (#34147908)
That's a cool library. I note that WolframAlpha handles this type of stuff readily. Does anyone ever bundle Wolfram products into theirs to handle natural language type things? I'm not immediately sure of the licensing framework, but it would seem nice to be able to do that.

Edit: It seems that WolframAlpha does have an HTTP API.

https://products.wolframalpha.com/api/documentation

I'm curious if anyone has used it. It costs but it could save an immense amount of time.

Re:Safari's date-picker is the cause of 1/3 of our customer ... by andrepd on Tuesday December 27, 2022 @07:12AM (#34147976)
Embedding wolframalpha is probably overkill, when all you need is simply a small arithmetic expression parser and to understand expressions like "next month" or "2 days ago", which even tools like GNU date support.
Re:Safari's date-picker is the cause of 1/3 of our customer ... by bmitc on Tuesday December 27, 2022 @07:57AM (#34148220)
For dates, probably, but I was more curious about other natural language use cases.
Re:Safari's date-picker is the cause of 1/3 of our customer ... by throwaway2037 on Tuesday December 27, 2022 @09:36AM (#34148999)
Hat tip that you mention GNU date. I am surprised each time I use that feature and it manages to produce the date that I wanted.
Re:Safari's date-picker is the cause of 1/3 of our customer ... by gernb on Tuesday December 27, 2022 @10:26AM (#34149430)
So you do you handle every language or just English. Can I write 来週の木曜日? or "hier" etc...