Skip to content

Commit

Permalink
fix bug #707
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierfriard committed Jan 25, 2024
1 parent d4aeedb commit 372515d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions boris/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4822,7 +4822,7 @@ def keyPressEvent(self, event) -> None:

else: # no scan sampling
if self.pj[cfg.OBSERVATIONS][self.observationId].get(cfg.START_FROM_CURRENT_TIME, False):
memLaps = dec(str(util.seconds_of_day(datetime.datetime.now())))
memLaps = util.seconds_of_day(datetime.datetime.now())
elif self.pj[cfg.OBSERVATIONS][self.observationId].get(cfg.START_FROM_CURRENT_EPOCH_TIME, False):
memLaps = dec(time.time())
else:
Expand Down Expand Up @@ -4851,7 +4851,7 @@ def keyPressEvent(self, event) -> None:
elif ek == Qt.Key_Enter and event.text(): # click from coding pad or subjects pad
ek_unichr = ek_text

logging.debug(f"ek_unichr {ek_unichr}")
logging.debug(f"{ek_unichr = }")

if ek == Qt.Key_Enter and event.text(): # click from coding pad or subjects pad
ek_unichr = ""
Expand Down
17 changes: 12 additions & 5 deletions boris/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,21 +786,28 @@ def complete(lst: list, max_: int) -> list:

def datetime_iso8601(dt) -> str:
"""
current date time in ISO8601 format without milliseconds
current date time in ISO8601 format without microseconds
example: 2019-06-13 10:01:02
Returns:
str: date time in ISO8601 format
str: date time in ISO8601 format without microseconds
"""
return dt.isoformat(" ").split(".")[0]
return dt.isoformat(sep=" ", timespec="seconds")


def seconds_of_day(timestamp) -> dec:
def seconds_of_day(timestamp: dt.datetime) -> dec:
"""
return the number of seconds since start of the day
Returns:
dev: number of seconds since the start of the day
"""

return dec((timestamp - dt.datetime.combine(dt.date(), dt.time(0))).total_seconds()).quantize(dec("0.001"))
# logging.debug("function: seconds_of_day")
# logging.debug(f"{timestamp = }")

t = timestamp.time()
return dec(t.hour * 3600 + t.minute * 60 + t.second + t.microsecond / 1000000).quantize(dec("0.001"))


def sorted_keys(d: dict) -> list:
Expand Down

0 comments on commit 372515d

Please sign in to comment.