Unexpected results when comparing time instances
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Reproduzca las comparaciones notificadas entre instancias de time y datetime conscientes de la zona horaria en las versiones de CPython indicadas. Rastree los puntos de entrada de comparación de time y datetime para determinar por qué cruzar una fecha local cambia el resultado y añada cobertura de regresión que muestre la igualdad esperada para tiempos absolutos equivalentes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug report
When comparing two time instances with different timezone, there are some unexpected result in some cases.
from datetime import datetime, time, timezone, timedelta
# Two time instances with the same absolute time in different time zones
t1 = time(hour = 0, tzinfo = timezone(timedelta(hours=1)))
t2 = time(hour = 7, tzinfo = timezone(timedelta(hours=8)))
print(t1 == t2) # True
# Another time instances with the same absolute time in different time zones, and local date is different
t3 = time(hour = 23, tzinfo = timezone(timedelta(hours=0)))
t4 = time(hour = 7, tzinfo = timezone(timedelta(hours=8)))
print(t3 == t4) # False, UNEXPECTED
# Two datetime instances with the same absolute time in different time zones and different local date
d1 = datetime(2022, 10, 10, hour = 23, tzinfo = timezone(timedelta(hours=0)))
d2 = datetime(2022, 10, 11, hour = 7, tzinfo = timezone(timedelta(hours=8)))
print(d1 == d2) # True, make sense
print(d1.timetz() == d2.timetz()) # False, UNEXPECTED
If two times with different timezones have the same absolute time, then thay should be equle. However, when the local dates of the two times are different, the comparison will be false even if the absolute time is the same.
As in the code above, the comparison between two datetimes has expected result, even though their local dates is different. However if we compare the time extracted from these two datetimes, the result will be false.
Your environment
- CPython versions tested on: 3.9, 3.10
- Operating system and architecture: Windows, macOS
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 558
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python/cpython
-
docs pending
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
stdlib type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
build type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
stdlib topic-email type-feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Todos los issues de python/cpython
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
PolicyEngine/policyengine-us#9559 ·
-
priority: p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
googleapis/librarian#7636 ·
-
from:qa priority:P2 reliability tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
spec-kitty/spec-kitty#4874 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100