Conversation
bcalou
left a comment
There was a problem hiding this comment.
Attention à bien suivre les pré-requis du readme
| test_date.test_invalid_dates() | ||
|
|
||
| test_algorithm = TestAlgorithm() | ||
| test_algorithm.test_algorithm() |
There was a problem hiding this comment.
Attention, le fichier main doit demander la date à l'utilisasteur qui lance le script (voir readme).
Il ne doit pas appeler les tests, qui sont appelés par la commande uniittest (voir readme aussi).
| def is_valid_date(date: str) -> bool: | ||
| return True | ||
| try: | ||
| year, month, day = map(int, date.split('-')) |
| except ValueError: | ||
| pass | ||
|
|
||
| return False |
There was a problem hiding this comment.
Rappellons que l'algo doit expliquer à l'utilisateur quelle est son erreur de saisie (pas dans le détail, mais au mois si c'est un problème de format ou de date non existante). Probablement à l'aide de print
| if 1 <= month <= 12 and 1 <= day <= 31: | ||
| if month in [4, 6, 9, 11] and day > 30: | ||
| return False | ||
| elif month == 2: # February | ||
| if day > 29: | ||
| return False | ||
| elif day == 29 and not (year % 4 == 0 and | ||
| (year % 100 != 0 or year % 400 == 0)): | ||
| return False # February 29 is only valid in leap years |
There was a problem hiding this comment.
Trouver comment applatir un peu cette structure très imbriquée ?
| week_days = ["Sunday", "Monday", | ||
| "Tuesday", "Wednesday", | ||
| "Thursday", "Friday", "Saturday"] |
There was a problem hiding this comment.
Utiliser une constante en haut du fichier, et plutôt un tuple, structure immutable
| return week_days[day_of_week] | ||
|
|
||
|
|
||
| def get_year_anchor(year: int) -> int: |
There was a problem hiding this comment.
Vu ensemble, clarifier si possible
|
Le programme doit demander une date à l'utilisateur, ce qu'il ne fait pas. |
No description provided.