mojombo / chronic

Chronic is a pure Ruby natural language date parser.
http://injekt.github.com/chronic
MIT License
3.23k stars 452 forks source link

Array of dates #395

Closed edumoreira1506 closed 4 years ago

edumoreira1506 commented 4 years ago

The issue #379 said about return one array of dates, like input be:

[
     {
          'options': {},
          'text': '2012-08-02T13:00:00'
     },
     {
          'options': {},
          'text': '2012-08-02T13:00:00+01:00'
     },
]

And output: [2012-08-02 13:00:00 -0300, 2012-08-02 13:00:00 +0100, 2019-09-10 12:00:00 -0300]

So I added a new method, parse_array than receives a array in input and use the same method of "Chronic.parse" for parse the dates and return an array of dates :)

davispuh commented 4 years ago

This doesn't solve #379 in that issue problem is that Chronic.parse('yesterday and today') returns just one date not both.

Also I don't really see this that useful, everyone can iterate it themselves and they might have different structure anyway.

edumoreira1506 commented 4 years ago

Oh, ok. I thought then that will be more easy for create a method that returns a array of dates, because currently we need to do manually this iterating over array and using the method and are some situations that this way would be easier, for example get dates from database and need to parse all of them or parse array of strings that user send something like one "schedule", but ok.