Skip to content

Commit

Permalink
Merge pull request #154 from asmorodskyi/fix_strfmt_error
Browse files Browse the repository at this point in the history
Allow not defined first and last seen
  • Loading branch information
asmorodskyi authored Jul 21, 2022
2 parents c803665 + 69adbda commit 7544bdc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ocw/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ def ttl_formated(self):

def all_time_fields(self):
all_time_pattern = "(age={}, first_seen={}, last_seen={}, ttl={})"
first_fmt = self.first_seen.strftime('%Y-%m-%d %H:%M')
last_fmt = self.last_seen.strftime('%Y-%m-%d %H:%M')
first_fmt = 'None'
last_fmt = 'None'
if (self.first_seen):
first_fmt = self.first_seen.strftime('%Y-%m-%d %H:%M')
if (self.last_seen):
last_fmt = self.last_seen.strftime('%Y-%m-%d %H:%M')
return all_time_pattern.format(self.age_formated(), first_fmt, last_fmt, self.ttl_formated())

def tags(self):
Expand Down

0 comments on commit 7544bdc

Please sign in to comment.