Skip to content

time

frog.hardware.plugins.time ¤

This module contains interfaces for querying time sources.

Classes¤

Functions¤

get_current_time() ¤

Read the current time, with optional time offset.

If the time device is not connected or the operation fails, local time is returned.

Source code in frog/hardware/plugins/time/__init__.py
14
15
16
17
18
19
20
21
22
23
def get_current_time() -> datetime:
    """Read the current time, with optional time offset.

    If the time device is not connected or the operation fails, local time is returned.
    """
    time = datetime.now()
    if dev := get_time_instance():
        time += timedelta(seconds=dev.get_time_offset())

    return time

get_time_instance() ¤

Get the instance of the current time source if connected or None.

Source code in frog/hardware/plugins/time/__init__.py
 9
10
11
def get_time_instance() -> TimeBase | None:
    """Get the instance of the current time source if connected or None."""
    return get_device_instance(TimeBase)