You have been tasked to write a service which ingests events. Each event has a date associated with it, but you notice that 3 different formats are being submitted to your service's endpoint:
"01/01/1970""January 1, 1970""Thursday, January 1, 1970"You can see there are some similarities between each of them, and decide to write some composable regular expression patterns.
Implement day, month, and year to return a string pattern which, when executed, would match the numeric components in "01/01/1970" (dd/mm/yyyy). The date and month may appear as 1 or 01 (left padded with zeroes).
Do not worry about error checking. You can assume you will always be passed a valid numeric component.
(day "31")
;;=> "31"
(month "12")
;;=> "12"
(year "1970")
;;=> "1970"Implement day-name and month-name to return a string pattern which, when executed, would match any named day of the week and the named month of the year respectively.
(day-name "Tuesday")
;;=> "Tuesday"
(month-name "June")
;;=> "June"Implement capture-day, capture-month, capture-year, capture-day-name, capture-month-name to return a map of the respective components to the names: "day", "month", "year", "day-name", "month-name"
(capture-month-name "December")
;;=> {:month-name "December"}Implement capture-numeric-date, capture-month-name-date, and capture-day-month-name-date to return a map of the components from part 3 using the respective date format.
(capture-numeric-date "01/01/1970")
;;=> {:day "01", :month "01", :year "1970"}You have been tasked to write a service which ingests events. Each event has a date associated with it, but you notice that 3 different formats are being submitted to your service's endpoint:
"01/01/1970""January 1, 1970""Thursday, January 1, 1970"You can see there are some similarities between each of them, and decide to write some composable regular expression patterns.
Implement day, month, and year to return a string pattern which, when executed, would match the numeric components in "01/01/1970" (dd/mm/yyyy). The date and month may appear as 1 or 01 (left padded with zeroes).
Do not worry about error checking. You can assume you will always be passed a valid numeric component.
(day "31")
;;=> "31"
(month "12")
;;=> "12"
(year "1970")
;;=> "1970"Implement day-name and month-name to return a string pattern which, when executed, would match any named day of the week and the named month of the year respectively.
(day-name "Tuesday")
;;=> "Tuesday"
(month-name "June")
;;=> "June"Implement capture-day, capture-month, capture-year, capture-day-name, capture-month-name to return a map of the respective components to the names: "day", "month", "year", "day-name", "month-name"
(capture-month-name "December")
;;=> {:month-name "December"}Implement capture-numeric-date, capture-month-name-date, and capture-day-month-name-date to return a map of the components from part 3 using the respective date format.
(capture-numeric-date "01/01/1970")
;;=> {:day "01", :month "01", :year "1970"}