fix: Corregido el cálculo del tiempo pra el comando /status#37
Open
misanram wants to merge 1 commit intopythoncanarias:masterfrom
Open
fix: Corregido el cálculo del tiempo pra el comando /status#37misanram wants to merge 1 commit intopythoncanarias:masterfrom
misanram wants to merge 1 commit intopythoncanarias:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
La función util.since recibe dos parámetros:
dt:
"""datetime is the date to calculate the difference from
reference. If not used, take the value from the current
datetime."""
y reference:
"""datetime is the datetime used to get the difference
ir delta. If not defined, default value is since the definition
of the function, this is,since the moment the current run of the
program started.
En la actualidad se llama a la función desde (bot.py:53) con un único parámetro y con el valor de "self.started_at", que es un valor constante y que contiene el valor datetime del momento del arranque del bot.
El parámetro "reference" tiene como valor por defecto datetime.datetime.now() Ese valor se evalúa en el momento de importar la función, con lo que queda con un valor constante durante la ejecución del bot, solo unas milésimas de segundo mayor que "self.started_a"
Al llamar a la función util.since, el valor de los parámetros queda así:
dt = self.started_at
reference = unos milisegundos mayor que el anterior
Posteriormente la lógica de la función devuelve de forma correcta 0 seconds, ya que el delta calculado es mucho menor de 1 sec
Solución propuesta: