To get a use out of this helpful function catch in the same order of passed parameters
(labels)
| 40 | |
| 41 | |
| 42 | def get_time(labels): |
| 43 | """To get a use out of this helpful function |
| 44 | catch in the same order of passed parameters""" |
| 45 | if not isinstance(labels, list): |
| 46 | labels = [labels] |
| 47 | |
| 48 | results = [] |
| 49 | |
| 50 | for label in labels: |
| 51 | if label == "this_minute": |
| 52 | results.append(datetime.now().strftime("%M")) |
| 53 | |
| 54 | if label == "this_hour": |
| 55 | results.append(datetime.now().strftime("%H")) |
| 56 | |
| 57 | elif label == "today": |
| 58 | results.append(datetime.now().strftime("%Y-%m-%d")) |
| 59 | |
| 60 | results = results if len(results) > 1 else results[0] |
| 61 | |
| 62 | return results |