Skip to content

Commit

Permalink
WIP minor fixes in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroangelini committed Oct 15, 2024
1 parent f795057 commit ca48e7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def init_config(self, config_dir: str | None = None, verbose: bool = False) -> N
f"could not find file, saving default config {self.saved_configs = }"
)
try:
config_file_path.parent.mkdir(parents=True, exist_ok=True)
with config_file_path.open("w", encoding="utf8") as conf_fp:
json.dump(
obj=self.saved_configs,
Expand Down
7 changes: 5 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def parse_interval(input: str) -> timedelta:
Returns:
timedelta: rounded timedelta
"""
if not input:
if not input or input == "0":
return timedelta(seconds=0)

now = datetime.now(UTC)
Expand All @@ -60,7 +60,10 @@ def human_date_str(input: datetime | None, when_now: datetime | None = None) ->
if when_now is None:
when_now = datetime.now(tz=UTC)
if abs(input - when_now) < timedelta(days=1):
return human_readable.date_time(input, minimum_unit="minutes")
return human_readable.date_time(
input.replace(tzinfo=None), # timezone hack so the human_readable works
minimum_unit="seconds",
)
else:
return human_readable.date(input.date())

Expand Down

0 comments on commit ca48e7a

Please sign in to comment.