Commit Graph

63 Commits

Author SHA1 Message Date
Dan Halbert 698a392cf1
Merge pull request #4762 from Neradoc/small-timestamps-if-epoch-2000
time.localtime: low timestamps when epoch is 2000
2021-07-15 15:08:09 -04:00
Jeff Epler 52540a9830 Rename EXTENDED_FIELDS -> MP_TYPE_EXTENDED_FIELDS 2021-07-12 06:57:59 -05:00
Jeff Epler 7302bc09a7 rename the type flag to EXTENDED for consistency 2021-07-09 14:59:37 -05:00
Jeff Epler 21e2dfaee2 Fix type checking against struct time 2021-07-07 08:43:18 -05:00
Jeff Epler d37f8a1a5a milestone: a selection of builds succeed 2021-07-06 10:57:44 -05:00
Jeff Epler df56ba207f WIP 2021-07-06 09:25:56 -05:00
microDev fd681ca70a
minor fix for struct_time docs 2021-06-29 08:11:16 +05:30
Jeff Epler 3dcd603e39 time: Fix and better document time.struct_time constructor
INCOMPATIBLE CHANGE: struct_time(1,2,3,4,5,6,7,8,9) is now _rejected_
just as on standad Python.

This incorrect constructor was added by me in #2327; I assumed
without even checking that the `struct_time` constructor was also
compatible with the `namedtuple` constructor, but it is not and has
always been rejected by standard Python (checked 2.7 and 3.9)

This commit restores the specific error message that we used for this
purpose, which was removed in the previous commit either out of laziness
or out of trying to reduce unneeded error strings. In this case, the
alternate string is too misleading (it refers to arguments, not to
sequence elements) so let's put the better message back.
2021-06-28 19:28:00 -05:00
Jeff Epler cac71a33fc time: Allow constructing a struct_time from another struct_time
Closes: #4917
2021-06-26 20:25:24 -05:00
Neradoc 3e5ec403fb time.localtime: low timestamps are ok if epoch is 2000 2021-05-14 12:20:49 +02:00
James Carr 106429a5e6
Update __init__.c
Minor typo.
2021-05-10 21:13:05 +01:00
Scott Shawcroft 3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
James Carr 65759622ea Add a missing parameter to an error message (Fixes #4505) 2021-03-29 23:03:14 +01:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert 9dbea36eac changed alarm.time API 2020-11-25 15:09:27 -05:00
Carl Karsten 2f058029e9 doc fix: remove the text about the non-existing clock specification 2020-09-12 15:25:04 -05:00
Jeff Epler 354edd9431
Merge pull request #3252 from ciscorn/pyi
Some improvements to the core module docs
2020-08-07 10:11:40 -05:00
Taku Fukada 56c898da80 Modify some Python stubs 2020-08-07 01:01:28 +09:00
Jeff Epler dddd25a776 Combine similar strings to reduce size of translations
This is a slight trade-off with code size, in places where a "_varg"
mp_raise variant is now used.  The net savings on trinket_m0 is
just 32 bytes.

It also means that the translation will include the original English
text, and cannot be translated.  These are usually names of Python
types such as int, set, or dict or special values such as "inf" or
"Nan".
2020-08-04 13:34:29 -05:00
dherrada 612c6bb86b
Merge branch 'main' into type_hints 2020-07-17 14:55:30 -04:00
Scott Shawcroft 08375c7930
Merge pull request #2780 from AndrewR-L/patch-1
busio/UART: Correct and clarify readline() return.
2020-07-13 16:29:58 -07:00
Diego Elio Pettenò 34b4993d63 Add license to some obvious files. 2020-07-06 19:16:25 +01:00
dherrada 4c5a9d1e3a Added type hints to time 2020-07-03 15:49:51 -04:00
dherrada d0d949cd24 Made every init return None 2020-07-03 14:23:34 -04:00
Scott Shawcroft c33542f978
Merge branch 'main' into patch-1 2020-07-02 13:56:09 -07:00
Scott Shawcroft cde6651721
Merge remote-tracking branch 'adafruit/master' into improve_verification 2020-05-12 18:23:59 -07:00
Scott Shawcroft 4e8de3c554
Swap sphinx to autoapi and the inline stubs 2020-05-12 17:28:24 -07:00
dherrada e4589543fb
Did time, touchio, uheap 2020-05-12 11:43:24 -04:00
DavePutz e7fc806034
Throw a NotImplementedError for time functions on boards without long ints
Fix for Issue #2812. Instead of reporting a missing attribute for functions such as time.time() and time.mktime(); platforms that do not have long integer support will raise a NotImplementedError
2020-05-08 16:33:26 -05:00
Dale Hawkins 8ae103e07c
Fix documentation typo: tm_minute should be tm_min 2020-03-16 09:07:10 -06:00
Dan Halbert cbd519bfa6 time.sleep() rounds to nearest msec 2020-02-07 10:24:11 -05:00
Dan Halbert 857d8ab40a improve time.monotonic_ns() accuracy from ms to us 2020-02-07 10:02:50 -05:00
Jeff Epler e188ae8b23 time: struct_time: allow construction like a namedtuple, too
Whenever there is more than one argument, delegate the operation to
namedtuple_make_new.  This allows other circuitpython-compatible
idioms, like with keywords
    time.struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0,
        tm_min=0, tm_sec=14, tm_wday=5, tm_yday=5, tm_isdst=-1)
with 9 positional arguments, etc.

The only vaguely plausible CPython behavior still not permitted in
CircuitPython that I found is constructing a timetuple from a length-9
list, a la
    time.struct_time(list(time.localtime())

Even better, by getting rid of an error message, the build shrinks a
tiny bit.
2019-11-26 08:45:44 -06:00
Jeff Epler 8f24ea48fb time: struct_time: allow construction from another struct_time
This doesn't cover ALL the cases that CPython permits for construction
of a struct_time, but it at least makes constructing from any namedtuple
work.

Closes: #2326
2019-11-26 08:45:40 -06:00
Jeff Epler f384d2dd80 shared-bindings/time: style 2019-08-18 08:11:14 -05:00
Jeff Epler 9d164965c9 localtime: don't hard-fault on argument type errors; handle localtime(float)
It turns out `mp_obj_int_get_checked` is not appropriate to call when
the argument is not of int or long type--the "checked" refers to guarding
against overflow/underflow, not type checking.

For compatibility with CPython, handle float arguments.

Closes: #2069
2019-08-17 20:49:25 -05:00
Dan Halbert 83129b8c63 BLE: peripheral client pairing (not yet bonding); fix time doc formatting 2019-07-30 14:26:26 -04:00
Scott Shawcroft cfe24b8532
Improve rST consistency for rst2pyi use 2019-05-30 19:02:47 -07:00
Jerry Needell 44bd9d1013 fix kw_arg checking for time.struct_time() 2019-01-25 14:57:31 -05:00
Scott Shawcroft 747f2cfe26
Add subclass support to displayio.
Also, swap make_news to accept a kwarg map and refine param checking.

Fixes #1237
2019-01-14 17:29:19 -08:00
Carlos 060b84a0fa Remove reference to clock_id on the function descriptiions 2018-11-18 10:43:28 -06:00
Carlos 55a9e2d697 Fix time.monotonic_ns docstring 2018-11-18 10:41:35 -06:00
Jeff Epler ec1aec1921 shared-bindings/time: introduce time.monotonic_ns
This is intended to be compatible with Python 3.7's time.monotonic_ns.
The "actual resolution" is 1ms due to this being the unit at which
common_hal_time_monotonic ticks.

Closes #519
2018-10-21 10:22:52 -05:00
Noralf Trønnes 39ee12d1ac Fix os.stat() to use 1970 epoch
Commit 95e70cd0ea 'time: Use 1970 epoch' changed epoch for the time
module, but not for other users. This patch does the same for the only
other core timeutils user: extmod/vfs_fat.c:fat_vfs_stat().
Other timeutils users: cc3200, esp8266 and stm32, are not changed.

Ports that don't use long ints, will still get wrong time values from
os.stat().
2018-08-25 20:43:02 +02:00
Scott Shawcroft 933add6cd8
Support internationalisation. 2018-08-07 14:58:57 -07:00
Dan Halbert e2e01efa84 compiles and runs; hangs on import storage;storage.VfsFat.<tab> 2018-07-13 22:51:10 -04:00
Noralf Trønnes 95e70cd0ea time: Use 1970 epoch
Use UNIX epoch to match CPython.
This overflows small int so time.{time,localtime,mktime} is only supported with long int.
Also remove some comment cruft in time_time().
2018-05-18 12:35:33 +02:00
Noralf Trønnes 8d1719f190 Add rtc module
Add an rtc module that provides a singleton RTC class with
- a datetime property to set and get time if the board supports it.
- a calbration property to adjust the clock.

There's also an rtc.set_time_source() method to override this RTC object using pure python.

The time module gets 3 methods:
- time.time()
- time.localtime()
- time.mktime()

The rtc timesource is used to provide time to the time module.

lib/timeutils is used for time conversions and thus only supports dates after 2000.
2018-04-16 12:49:10 +02:00