Skip to content

Commit

Permalink
correct for c++ -> python datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Jan 23, 2024
1 parent 4ef2801 commit 6684885
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion neo/rawio/plexon2rawio/plexon2rawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ def _parse_header(self):
# invalid datetime information if year is <1
if tmo.tm_year != 0:
microseconds = block_info['m_CreatorDateTimeMilliseconds'] * 1000
dt = datetime(year=tmo.tm_year, month=tmo.tm_mon, day=tmo.tm_mday, hour=tmo.tm_hour,
# tm_mon range is 0..11 https://cplusplus.com/reference/ctime/tm/
# python is 1..12 https://docs.python.org/3/library/datetime.html#datetime.datetime
# so month needs to be tm_mon+1; also tm_sec could cause problems in the case of leap
# seconds, but this is harder to defend against.
dt = datetime(year=tmo.tm_year, month=tmo.tm_mon+1, day=tmo.tm_mday, hour=tmo.tm_hour,
minute=tmo.tm_min, second=tmo.tm_sec, microsecond=microseconds)
# ignoring daylight saving time information for now as timezone is unknown

Expand Down

0 comments on commit 6684885

Please sign in to comment.