Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add tz kwarg to from_timestamp()#1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 8 commits intomasterfromtz_from_timestamp
May 1, 2020
Merged

Conversation

Bibo-Joshi
Copy link
Member

Closing#1613 as addendum to#1506

@tsnoam@plammens Is this, what was missing or am I overlooking half of it? :D

plammens reacted with thumbs up emoji
@Bibo-JoshiBibo-Joshi added this to the12.5 milestoneNov 18, 2019
@plammens
Copy link
Contributor

plammens commentedNov 18, 2019
edited
Loading

With this the default is an awaredatetime, while before it was naive—e.g.telegram.Message.date will return an awaredatetime. If we wantMessage.date and the like to keep being naive, the calls in thede_json of sometelegram classes, e.g.

data['date']=from_timestamp(data['date'])
would also need to be changed todata['date'] = from_timestamp(data['date']).replace(tzinfo=None). Or the default forfrom_timestamp could be kept as naive UTC to avoid the breaking change.

Otherwise I think the only problem is handlingNone: passingNone totzinfo will return a naive datetime inlocal rather than UTC. Maybe something like this instead:

iftzinfoisnotNone:returndtm.datetime.fromtimestamp(unixtime,tz=tzinfo)else:returndtm.datetime.utcfromtimestamp(unixtime)

@Bibo-Joshi
Copy link
MemberAuthor

With this the default is an awaredatetime, while before it was naive—e.g.telegram.Message.date will return an awaredatetime. If we wantMessage.date and the like to keep being naive, the calls in thede_json of sometelegram classes, e.g.

data['date']=from_timestamp(data['date'])

would also need to be changed todata['date'] = from_timestamp(data['date']).replace(tzinfo=None). Or the default forfrom_timestamp could be kept as naive UTC to avoid the breaking change.

Good point. Let's wait, what tsoam says.

Otherwise I think the only problem is handlingNone: passingNone totzinfo will return a naive datetime inlocal rather than UTC. Maybe something like this instead:

iftzinfoisnotNone:returndtm.datetime.fromtimestamp(unixtime,tz=tzinfo)else:returndtm.datetime.utcfromtimestamp(unixtime)

Oh, shuh, you're absolutely right. Will update tonight.

plammens reacted with thumbs up emoji

@Bibo-Joshi
Copy link
MemberAuthor

Updated as suggested. About the failing tests:

  • Py2.7 fails becausedatetime has notimezone. But since this PR is only due for v12.5, which I reckon won't be released bevore 2020, when we drop Py2.7, I guess we don't reallyhave to adjust for that. Although, I wonder why it didn't fail on the first run …
  • As usual, I have no clue, what codecov wants from me 🤔

@Poolitzer
Copy link
Member

agree with the 2.7 part

@Bibo-Joshi
Copy link
MemberAuthor

@plammens Lost in translation … Thanks for clarifying!

@Bibo-JoshiBibo-Joshi added the 📋 pending-reviewwork status: pending-review labelNov 23, 2019
Copy link
Member

@tsnoamtsnoam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

one minor comment on a docstring. but LGTM, you can merge.

@tsnoam
Copy link
Member

actually, i just fixed the docstring myself.

you can merge from master and then you can merge this PR.

# Conflicts:#tests/conftest.py
@Bibo-JoshiBibo-Joshi merged commit7e23118 intomasterMay 1, 2020
@Bibo-JoshiBibo-Joshi deleted the tz_from_timestamp branchMay 1, 2020 20:55
@Bibo-JoshiBibo-Joshi mentioned this pull requestMay 23, 2020
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 17, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@plammensplammensplammens left review comments

@tsnoamtsnoamtsnoam approved these changes

Assignees
No one assigned
Labels
📋 pending-reviewwork status: pending-review
Projects
None yet
Milestone
12.6
Development

Successfully merging this pull request may close these issues.

4 participants
@Bibo-Joshi@plammens@Poolitzer@tsnoam

[8]ページ先頭

©2009-2025 Movatter.jp