Skip to content

Commit

Permalink
src/pynwb/file.py: Rewrite the file_create_date setting code
Browse files Browse the repository at this point in the history
Using an if/elif chain is easier to understand.
  • Loading branch information
t-b committed Jan 29, 2020
1 parent a41eaee commit f26740f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,12 @@ def __init__(self, **kwargs):
raise ValueError("'timestamps_reference_time' must be a timezone-aware datetime object.")

self.fields['file_create_date'] = getargs('file_create_date', kwargs)

if self.fields['file_create_date'] is None:
self.fields['file_create_date'] = datetime.now(tzlocal())
if isinstance(self.fields['file_create_date'], datetime):
self.fields['file_create_date'] = [datetime.now(tzlocal())]
elif isinstance(self.fields['file_create_date'], datetime):
self.fields['file_create_date'] = [self.fields['file_create_date']]

self.fields['file_create_date'] = list(map(_add_missing_timezone, self.fields['file_create_date']))

fieldnames = [
Expand Down

0 comments on commit f26740f

Please sign in to comment.