Skip to content

time: Add time module to provide strftime. #508

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
Dec 14, 2022

Conversation

iabdalkader
Copy link
Contributor

No description provided.

@andrewleech
Copy link
Contributor

FYI I've also got a recent open PR to add a time module with monotonic in #502

It'd certainly be trivial to merge them eventually.

It's probably worth you adding from time import * in __init__.py so this new module transparently includes everything from there too?

@iabdalkader
Copy link
Contributor Author

It's probably worth you adding from time import * in __init__.py so this new module transparently includes everything from there too?

I don't think it should import everything in there.

@andrewleech
Copy link
Contributor

In micropython, the C implementation of builtins are in the u modules, eg uos, ucollections. These are automatically shadowed to the non-u names if there's no other non-u implementation on path, eg os, collections for compatibility.

If there's a python / frozen version of the non-u version provided however that overrides the shadow; the intention is to allow python modules to extend the built-ins exactly like this PR is doing.

As-is, once this time.py is added to path, import time should no longer include the rest of the built in functionality?
In my understanding the python built-in packages should wrap / override the built-in C u version, see

That wayimport time will give access to everything in C utime as well as the new python functionality.

@iabdalkader
Copy link
Contributor Author

Ah okay, but you said :

It's probably worth you adding from time import * in init.py so this new module transparently includes everything from there too?

I think you meant from utime import * now that makes sense yes.

@andrewleech
Copy link
Contributor

andrewleech commented Jul 17, 2022

I think you meant from utime import * now that makes sense yes.

Ah geez sorry for the confusion, I missed the unwanted autocorrect!

@iabdalkader iabdalkader force-pushed the add_time branch 7 times, most recently from d7df55c to a0ee55c Compare December 13, 2022 07:06
iabdalkader and others added 2 commits December 14, 2022 11:57
@dpgeorge dpgeorge merged commit 8d653e9 into micropython:master Dec 14, 2022
@dpgeorge
Copy link
Member

Thanks for updating. Merged, and I removed the import re and associated global variable because it's no longer used.

I also added a unit test (taking out the test from time.py).

@iabdalkader iabdalkader deleted the add_time branch December 14, 2022 06:53
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.

3 participants