[Python] Python - Date parser that could get all the dates from a specific string input

Discussão em 'Python' iniciado por Stack, Junho 26, 2025.

  1. Stack

    Stack Membro Participativo

    Currently doing a task that has given to me which is partly related to machine learning. The task is to parse a string input from the user into a date, given that I could have 2 parameter for the function: date_from and date_to; something like the given example below.

    Any classes/functions that could help or an idea on how to do it would be a big help to me.

    2.a 8th of July -> 2018-07-08
    2.b July to December -> 2018-07 to 2018-12
    2.c July -> 2018-07
    2.d July 1st -> 2018-07-01
    2.e Last week -> 2018-08-02 (curr_date - 7days)
    2.f next week -> 2018-08-16 (curr_date + 7days)
    2.g today -> 2018-08-09
    2.h tomorrow -> 2018-08-10
    2.i next monday -> 2018-08-13
    2.j last monday -> 2018-07-30
    2.k next month -> 2018-09 (or curr_date + 30days)
    2.l last month -> 2018-07 (or curr_date - 30days)


    Currently I'm using Flask for the development and testing.

    Continue reading...

Compartilhe esta Página