Skip to content

Make the fields of times.DateTime private #14197

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2020

Conversation

GULPF
Copy link
Member

@GULPF GULPF commented May 2, 2020

See RFC's for motivation

Closes #nim-lang/RFCs#75, refs nim-lang/RFCs#211

@GULPF GULPF force-pushed the datetime-field-access branch from 8c095b9 to cc531fc Compare May 3, 2020 08:52
@Araq
Copy link
Member

Araq commented May 4, 2020

The non-deprecated accessor procs should be .inline, otherwise seems good to go.

@@ -276,8 +275,7 @@ type
dSun = "Sunday"

type
MonthdayRange* = range[0..31]
## 0 represents an invalid day of the month
MonthdayRange* = range[1..31]
HourRange* = range[0..23]
MinuteRange* = range[0..59]
SecondRange* = range[0..60]
Copy link
Member

@timotheecour timotheecour May 4, 2020

Choose a reason for hiding this comment

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

pre-existing but maybe add a comment saying that the range is 0..60 to account for leap seconds ? (I'm not even sure that's the reason, but it sure looks weird without an explanation otherwise)

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a comment. There's not really any good reason that the range includes 60, DateTime will never contain a leap second with the current implementation. The only difference it makes is that initDateTime allows timestamps with leap seconds

Copy link
Member

Choose a reason for hiding this comment

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

The only difference it makes is that initDateTime allows timestamps with leap seconds

I guess that's a good enough reason for existence? if possible you could add a test that calls initDateTime with a leap second, unless it's too much work because it would fail validation as currently implemented

@Araq Araq merged commit 48e7775 into nim-lang:devel May 6, 2020
EchoPouet pushed a commit to EchoPouet/Nim that referenced this pull request Jun 13, 2020
* Make the fields of `times.DateTime` private

* PR fixes
oakes added a commit to paranim/paravim that referenced this pull request Jun 15, 2020
@oakes
Copy link

oakes commented Jun 15, 2020

FYI for posterity, this is a breaking change for code that imports the module with from times import nil, since dt.month will now need to be times.month(dt) for example...i ended up switching to an unqualified import so it will work across versions.

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.

4 participants