Skip to content

Commit 6684885

Browse files
committed
correct for c++ -> python datetime
1 parent 4ef2801 commit 6684885

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

neo/rawio/plexon2rawio/plexon2rawio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ def _parse_header(self):
223223
# invalid datetime information if year is <1
224224
if tmo.tm_year != 0:
225225
microseconds = block_info['m_CreatorDateTimeMilliseconds'] * 1000
226-
dt = datetime(year=tmo.tm_year, month=tmo.tm_mon, day=tmo.tm_mday, hour=tmo.tm_hour,
226+
# tm_mon range is 0..11 https://cplusplus.com/reference/ctime/tm/
227+
# python is 1..12 https://docs.python.org/3/library/datetime.html#datetime.datetime
228+
# so month needs to be tm_mon+1; also tm_sec could cause problems in the case of leap
229+
# seconds, but this is harder to defend against.
230+
dt = datetime(year=tmo.tm_year, month=tmo.tm_mon+1, day=tmo.tm_mday, hour=tmo.tm_hour,
227231
minute=tmo.tm_min, second=tmo.tm_sec, microsecond=microseconds)
228232
# ignoring daylight saving time information for now as timezone is unknown
229233

0 commit comments

Comments
 (0)