Skip to content

Add validated RecordData time shifting - #916

Merged
tompollard merged 1 commit into
mainfrom
feature/record-data-shift-time
Dec 4, 2026
Merged

tompollard merged 1 commit into
mainfrom
feature/record-data-shift-time

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Add RecordData.shift_time(delta) as a validated edit. delta must be a datetime.timedelta; plain numbers are rejected.

  • A complete base date and time shift together, preserving microsecond precision.
  • A time without a date wraps within the day. Whole days have no visible effect because there is no calendar date to shift.
  • A date without a time accepts whole-day shifts only. The result gains midnight because a WFDB header cannot write a date without a time. A shifted date outside years 1–9999 raises ValueError when the edit is made.
  • The result has independent arrays and masks. Its source header and selection retain their provenance; the selected view and written header use the shifted timestamp. Comments, annotations and counter fields are unchanged.

The docs call out that source_header still contains the original timestamp. A caller preparing data for de-identification must also review comments and avoid sharing source provenance if it is sensitive.

Checks

  • Offline suite: 2,239 passed, 4 skipped, 23 deselected (using the project's compatible PhysioNet package path).
  • Ruff check and format passed; Sphinx docs build passed with warnings treated as errors.
  • Tests cover midnight, whole-day and fractional shifts, date-only normalization, missing timestamps, date-range errors, independent masks and prior sample edits, legacy-backed results, and read/write round trips. They assert the original date is absent from the written header and exercise iter_dataframes for shifted dates in 2100 and 1500, reusing Build DataFrames for records dated outside 1677 to 2262 #870's date-range behavior.

@tompollard
tompollard merged commit b57e255 into main Dec 4, 2026
19 checks passed
@tompollard
tompollard deleted the feature/record-data-shift-time branch December 4, 2026 18:16
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.

1 participant