Skip to content

Commit 77cddba

Browse files
author
Rodrigo Roldán
committed
fix: remove duplicate function
1 parent e41ffcc commit 77cddba

2 files changed

Lines changed: 4 additions & 27 deletions

File tree

src/eones/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ def format_date(date: Union[Date, datetime], fmt: str) -> str:
5858
"""
5959
if isinstance(date, Date):
6060
return date.format(fmt)
61-
elif isinstance(date, datetime):
61+
if isinstance(date, datetime):
6262
return date.strftime(fmt)
63-
else:
64-
raise TypeError(f"Expected Date or datetime object, got {type(date).__name__}")
63+
raise TypeError(f"Expected Date or datetime object, got {type(date).__name__}")
6564

6665

6766
def add_days(date: Date, days: int) -> Date:
@@ -129,10 +128,9 @@ def to_timestamp(date: Union[Date, datetime]) -> int:
129128
"""
130129
if isinstance(date, Date):
131130
return int(date.to_unix())
132-
elif isinstance(date, datetime):
131+
if isinstance(date, datetime):
133132
return int(date.timestamp())
134-
else:
135-
raise ValueError("Expected Date or datetime object")
133+
raise ValueError("Expected Date or datetime object")
136134

137135

138136
def from_timestamp(timestamp: Union[int, float], tz: str = "UTC") -> Date:

src/eones/interface.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -299,27 +299,6 @@ def _coerce_to_date(self, other) -> "Date":
299299

300300
return self._parser.parse(other)
301301

302-
@staticmethod
303-
def is_valid_format(date_str: str, formats: List[str]) -> bool:
304-
"""Check if a date string matches any of the provided formats.
305-
306-
Args:
307-
date_str: Date string to validate
308-
formats: List of format strings to try
309-
310-
Returns:
311-
bool: True if the string matches any format
312-
"""
313-
from datetime import datetime
314-
315-
for fmt in formats:
316-
try:
317-
datetime.strptime(date_str, fmt)
318-
return True
319-
except ValueError:
320-
continue
321-
return False
322-
323302
@staticmethod
324303
def sanitize_formats(formats: List[Any]) -> List[str]:
325304
"""Remove duplicates and invalid formats from a format list.

0 commit comments

Comments
 (0)