Conversation
|
J'aime bien |
bcalou
left a comment
There was a problem hiding this comment.
Bien, pas de problème majeur à part le fichier main
| def main() -> None: | ||
| print("Hello world") | ||
| user_input = input("Please enter a date in the format YYYY-MM-dd: ") | ||
|
|
||
| if is_valid_date(user_input): | ||
| print("The date is valid.") | ||
| else: | ||
| print("Error: The date is not valid.") |
There was a problem hiding this comment.
L'éxécution du fichier principal doit afficher le jour correspondant à la date, pas seulement la validité de la date
doomsday/algorithm.py
Outdated
| days: list[str] = [ | ||
| 'Sunday', | ||
| 'Monday', | ||
| 'Tuesday', | ||
| 'Wednesday', | ||
| 'Thursday', | ||
| 'Friday', | ||
| 'Saturday' | ||
| ] |
There was a problem hiding this comment.
Conseil : utiliser un tuple (immutable) et DAYS en majuscule (constante)
doomsday/date.py
Outdated
| from datetime import datetime | ||
|
|
||
|
|
||
| def is_valid_date(date_str) -> bool: |
| """ | ||
| Returns the weekday for the given date in the format YYYY-MM-dd. | ||
| """ | ||
| year, month, day = (int(i) for i in date.split('-')) |
doomsday/algorithm.py
Outdated
| return year % 400 == 0 or (year % 100 != 0 and year % 4 == 0) | ||
|
|
||
|
|
||
| def get_anchor_year(year): |
doomsday/algorithm.py
Outdated
| difference_multiple_of_7: int = century_year % 7 | ||
| # multiple of 7 equals or greater than century year | ||
| if difference_multiple_of_7 != 0: | ||
| difference_multiple_of_7 = 7 - difference_multiple_of_7 |
doomsday/algorithm.py
Outdated
|
|
||
| def get_anchor_year(year): | ||
| """Calculates the anchor day index for the given year.""" | ||
| century_year: int = year % 100 |
There was a problem hiding this comment.
Quel rapport ici avec le siècle ? (nommage de la variable trompeur)
doomsday/algorithm.py
Outdated
| """ | ||
| year, month, day = (int(i) for i in date.split('-')) | ||
|
|
||
| anchor_day_index = get_anchor_year(year) |
There was a problem hiding this comment.
Attention aux termes précis. Le nom de la fonction donne l'impression que c'est une année que l'on va récupérer
doomsday/algorithm.py
Outdated
| difference = day - doomsday_month[month - 1] | ||
| weekday_index = (anchor_day_index + difference) % 7 |
There was a problem hiding this comment.
Pas simple à comprendre sans commentaire
|
Quelques erreurs de formattage pycodestyle. |
No description provided.