Skip to content

Timestamp parsing failure with timezone information #586

@KellianL

Description

@KellianL

Description

The current implementation of _extract_timestamp() in src/powerapi/report/report.py, fails to parse valid ISO 8601 timestamps that include timezone information (e.g., '2025-04-03T12:36:20.800232411+00:00').
The function only handles ISO 8601 timestamps without timezone information.

Expected Behavior

The function should successfully parse ISO 8601 timestamps with timezone information.

Current Behavior

The function raises a ValueError when parsing timestamps with timezone information.

Example code

from datetime import datetime
from powerapi.report.report import Report

timestamp = '2025-04-03T12:36:20.800232411+00:00'

try:
    ts = Report._extract_timestamp(timestamp)
    print(f"Timestamp: {ts}")
except ValueError as e:
    print(f"Error: {e}")

Versions

powerapi : 2.10.0
python : 3.13.2

Optional notes

  • datetime.fromisoformat() was added in Python 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions