Skip to content

Commit

Permalink
V2.0.0 (#210)
Browse files Browse the repository at this point in the history
* improves: add wait_key

* improves: add wait_key

* chore: add scraping package

* refactor: rename CompanyDetails to Share

* refactor: rename CompanyDetails to Share

* refactor: add financial info

* fix: fixed parser datetime

* fix: fixed parser datetime

* fix: fixed time_format
  • Loading branch information
jlsneto authored Aug 15, 2024
1 parent 2732948 commit 4e42425
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cereja/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
from ._requests import request
from . import scraping

VERSION = "2.0.0.final.0"
VERSION = "2.0.0.final.1"

__version__ = get_version_pep440_compliant(VERSION)


Expand Down
16 changes: 13 additions & 3 deletions cereja/utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,28 @@ def get_attr_if_exists(obj: Any, attr: str) -> Union[object, None]:
def time_format(seconds: float, format_="%H:%M:%S") -> Union[str, float]:
"""
Default format is '%H:%M:%S'
If the time exceeds 24 hours, it will return a format like 'X days HH:MM:SS'
>>> time_format(3600)
'01:00:00'
>>> time_format(90000)
'1 days 01:00:00'
"""
# this because NaN
# Check if seconds is a valid number
if seconds >= 0 or seconds < 0:
time_ = time.strftime(format_, time.gmtime(abs(seconds)))
# Calculate the absolute value of days
days = int(seconds // 86400)
# Format the time
time_ = time.strftime(format_, time.gmtime(abs(seconds) % 86400))
# Return with days if more than 24 hours
if days > 0:
return f"{days} days {time_}"
# Return the formatted time
if seconds < 0:
return f"-{time_}"
return time_
return seconds # NaN
return seconds # Return NaN or any invalid input as it is


def fill(value: Union[list, str, tuple], max_size, with_=" ") -> Any:
Expand Down

0 comments on commit 4e42425

Please sign in to comment.