Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedargrovestudios/circuitpython_dst_adjuster
A CircuitPython helper to adjust to North American Daylight Saving Time (DST).
https://github.com/cedargrovestudios/circuitpython_dst_adjuster
circuitpython circuitpython-community-bundle daylight-saving-time helper structured-time
Last synced: about 1 month ago
JSON representation
A CircuitPython helper to adjust to North American Daylight Saving Time (DST).
- Host: GitHub
- URL: https://github.com/cedargrovestudios/circuitpython_dst_adjuster
- Owner: CedarGroveStudios
- License: mit
- Created: 2022-10-21T05:38:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T02:01:18.000Z (almost 2 years ago)
- Last Synced: 2023-03-11T15:06:04.297Z (almost 2 years ago)
- Topics: circuitpython, circuitpython-community-bundle, daylight-saving-time, helper, structured-time
- Language: Python
- Homepage:
- Size: 584 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Introduction
============.. image:: https://img.shields.io/discord/327254708534116352.svg
:target: https://adafru.it/discord
:alt: Discord.. image:: https://github.com/CedarGroveStudios/CircuitPython_DST_Adjuster/workflows/Build%20CI/badge.svg
:target: https://github.com/CedarGroveStudios/CircuitPython_DST_Adjuster/actions
:alt: Build Status.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: BlackA CircitPython helper to detect and adjust North American Daylight Saving Time (DST).
``Adjust DST`` converts Standard Time (xST) to North American DST. Input to this
function is a structured time object in xST. The function returns a structured
time object adjusted to a DST value if appropriate and a flag indicating the DST
adjustment was made. The helper cannot detect DST for a structured time object
that is encoded as DST... image:: https://github.com/CedarGroveStudios/CircuitPython_DST_Adjuster/blob/main/media/WARNING.jpg
Dependencies
=============
This driver depends on:* `Adafruit CircuitPython `_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle `_
or individual libraries can be installed using
`circup `_.Installing to a Connected CircuitPython Device with Circup
==========================================================Make sure that you have ``circup`` installed in your Python environment.
Install it with the following command if necessary:.. code-block:: shell
pip3 install circup
With ``circup`` installed and your CircuitPython device connected use the
following command to install:.. code-block:: shell
circup install cedargrove_dst_adjuster
Or the following command to update an existing version:
.. code-block:: shell
circup update
Usage Example
=============.. code-block:: python
import time
from cedargrove_dst_adjuster import adjust_dst# Today's date: 11/01/2020 00:00 Standard Time (xST)
datetime = time.struct_time((2020, 11, 1, 0, 0, 0, 6, 0, -1))# Check datetime and adjust if DST
adj_datetime, is_dst = adjust_dst(datetime)if is_dst:
flag_text = "DST"
else:
flag_text = "xST"# Print the submitted time
print(
" {}/{}/{} {:02}:{:02}:{:02} week_day={}".format(
datetime.tm_mon,
datetime.tm_mday,
datetime.tm_year,
datetime.tm_hour,
datetime.tm_min,
datetime.tm_sec,
datetime.tm_wday,
)
)# Print the adjusted time
print(
"{}: {}/{}/{} {:02}:{:02}:{:02} week_day={}".format(
flag_text,
adj_datetime.tm_mon,
adj_datetime.tm_mday,
adj_datetime.tm_year,
adj_datetime.tm_hour,
adj_datetime.tm_min,
adj_datetime.tm_sec,
adj_datetime.tm_wday,
)
)Documentation
=============
API documentation for this library can be found `here `_.For information on building library documentation, please check out
`this guide `_.Contributing
============Contributions are welcome! Please read our `Code of Conduct
`_
before contributing to help this project stay welcoming.