Skip to content

Return timestamps as datetime objects #14

@DevilXD

Description

@DevilXD

Hi 👋

Describe the solution you'd like

I think Submission.created_utc should contain a datetime object, instead of just the unix timestamp.

Describe alternatives you've considered

Currently, one has to wrap those themselves:

from datetime import datetime, timezone

post: Submission
posted_at = datetime.fromtimestamp(post.created_utc, timezone.utc)

Now, I have two variables, post and posted_at, that have information tied together, instead of just having one post variable, and accessing everything I'd need from it. Doing this:

# overwrite the attribute
post.created_utc = datetime.fromtimestamp(post.created_utc, timezone.utc)

... is risky, because the library may not expect this data type to be there.

Additional context

This would have to be applied to every object with a created_utc attribute, including submissions, comments, redditors, live threads, messages, etc. The same should probably apply to the edited attribute, which appears to be either false or specify the edition timestamp: https://i.imgur.com/1Mwbi9X.png In this case, the attribute should probably be either None when not edited, and datetime specifying the edition time when edited. The current documentation of "Whether or not the submission has been edited." is slightly misleading on this fact right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions