Skip to content

Commit

Permalink
Added strftime() method to fix #870
Browse files Browse the repository at this point in the history
  • Loading branch information
APCBoston authored and diegogangl committed Mar 22, 2024
1 parent 2ea96eb commit 784fa83
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions GTG/core/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ def _cast_for_operation(self, other, is_comparison: bool = True):
return (self.dt_by_accuracy(Accuracy.fuzzy),
other.dt_by_accuracy(Accuracy.fuzzy))

def strftime(self,format: str) -> str:
if isinstance(self.dt_value, (date,datetime)):
return self.dt_value.strftime(format)
else:
# If dt_value is not an instance of datetime.date or datetime.datetime, use self.date() to get one of those
# and call its strftime() method
temp_date = self.date()
return temp_date.strftime(format)


def __add__(self, other):
a, b = self._cast_for_operation(other, is_comparison=False)
return a + b
Expand Down

0 comments on commit 784fa83

Please sign in to comment.