Skip to content

ENH: Allow setting non-UTC timezone in set_meas_date (#9953) - #14436

Open
ishaaaan17 wants to merge 1 commit into
mne-tools:mainfrom
ishaaaan17:fix/allow-non-utc-meas-date
Open

ishaaaan17 wants to merge 1 commit into
mne-tools:mainfrom
ishaaaan17:fix/allow-non-utc-meas-date

Conversation

@ishaaaan17

Copy link
Copy Markdown
Contributor

summary of changes

fixes #9953.
this builds on and finishes the abandoned PR #10970 by @TzionaN, rebased onto the current main and adapted to mne/_fiff/meas_info.py.

before this, set_meas_date raised a ValueError if you gave it a timezone-aware datetime object with a non-UTC timezone, while setting info['utc_offset'] directly was deprecated.

this change does these things:

  1. set_meas_date now accepts timezone-aware non-UTC datetime objects, converts them to UTC for info['meas_date'], and fills info['utc_offset'] automatically with the formatted offset (for example +02:00 or -05:00).
  2. sets info['utc_offset'] = None when meas_date is in UTC or None.
  3. adds parsing of the offset in ISO8601 strings in _handle_meas_date.
  4. adds unit tests in mne/_fiff/tests/test_meas_info.py (including a FIFF I/O save/reload roundtrip and anonymization) and in mne/tests/test_annotations.py.
  5. adds a changelog entry in doc/changes/dev/9953.bugfix.rst.

ai disclosure

i used an ai assistant to trace how utc_offset is formatted in FIFF and how Info.set_meas_date is structured across mne/_fiff/meas_info.py and mne/annotations.py. i checked the offset calculation logic, wrote the round-trip and anonymization tests, formatted the code with ruff, and ran the pytest suite locally before pushing.

@ishaaaan17
ishaaaan17 force-pushed the fix/allow-non-utc-meas-date branch from 526462e to 26239aa Compare October 20, 2026 10:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot set non-UTC timezone

1 participant