No description
Find a file
Jeff Epler 13f93325d3 total_seconds: Fix precision problem
Since CircuitPython floats have very small precision, the "total_seconds"
method was not very useful for large timedeltas.

Instead of always returning a float, use pure-integer arithmetic (and
return an int) if either:
 * the length of time is big (1<<21 is 2097152 seconds or about 24 days)
 * the number of microseconds is zero

Otherwise, for small values with nonzero microseconds, use floating-point
math.

The cut-off point was chosen because in CircuitPython float arithmetic,
2097151.0+0.5 is different from 2097151.0, but 2097152.0+0.5 and
2097152.0 are *the same float*.
2021-03-22 15:27:49 -05:00
.github/workflows pylint to precommit 2021-03-02 18:34:46 -06:00
docs Initial commit! 2021-01-27 15:57:25 -05:00
examples Added fromisoformat() to date and datetime 2021-02-18 10:03:54 -08:00
LICENSES Initial commit! 2021-01-27 15:57:25 -05:00
tests last issue 2021-03-17 12:16:21 -04:00
.gitignore Initial commit! 2021-01-27 15:57:25 -05:00
.pre-commit-config.yaml tests pylint pre-commit hook 2021-03-08 18:31:42 -06:00
.pylintrc "Increase duplicate code check threshold 2021-03-19 13:48:46 -04:00
.readthedocs.yml Initial commit! 2021-01-27 15:57:25 -05:00
adafruit_datetime.py total_seconds: Fix precision problem 2021-03-22 15:27:49 -05:00
CODE_OF_CONDUCT.md Initial commit! 2021-01-27 15:57:25 -05:00
LICENSE Initial commit! 2021-01-27 15:57:25 -05:00
pyproject.toml Initial commit! 2021-01-27 15:57:25 -05:00
README.rst add note about lib. footprint 2021-01-27 17:30:16 -05:00
README.rst.license Initial commit! 2021-01-27 15:57:25 -05:00
requirements.txt Initial commit! 2021-01-27 15:57:25 -05:00
setup.py Initial commit! 2021-01-27 15:57:25 -05:00

SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries

SPDX-License-Identifier: MIT