When quering KB, (our) KB tends to autoComplete a date e.g. - 1996 --> 1996-01-01 - 1906-04-18 --> 1906-04-18 05:12:00
(date_string)
| 70 | |
| 71 | |
| 72 | def date_post_process(date_string): |
| 73 | """ |
| 74 | When quering KB, (our) KB tends to autoComplete a date |
| 75 | e.g. |
| 76 | - 1996 --> 1996-01-01 |
| 77 | - 1906-04-18 --> 1906-04-18 05:12:00 |
| 78 | """ |
| 79 | pattern_year_month_date = r"^\d{4}-\d{2}-\d{2}$" |
| 80 | pattern_year_month_date_moment = r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$" |
| 81 | |
| 82 | if re.match(pattern_year_month_date_moment, date_string): |
| 83 | if date_string.endswith('05:12:00'): |
| 84 | date_string = date_string.replace('05:12:00', '').strip() |
| 85 | elif re.match(pattern_year_month_date, date_string): |
| 86 | if date_string.endswith('-01-01'): |
| 87 | date_string = date_string.replace('-01-01', '').strip() |
| 88 | return date_string |
| 89 | |
| 90 | |
| 91 |
no outgoing calls
no test coverage detected