Home2L - Python API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
Functions
Time

Description

Date and time helpers.

Collaboration diagram for Time:

Functions

def TicksNow ()
 
def TicksToday ()
 
def TicksOfDate (dy, dm, dd)
 
def TicksOfTime (th, tm, ts)
 
def TicksOfSeconds (*args)
 
def TicksOfMillis (ms)
 
def TicksAbsFromMonotic (tm)
 
def TicksMonotonicFromAbs (ta)
 
def TicksAbsStr (ticks)
 
def TicksRelStr (ticks)
 
def TicksAbsOf (something)
 
def TicksRelOf (something)
 
def TicksToPyDateTime (t)
 
def TicksToPyTimeDelta (t)
 
def TicksFromUTC (t)
 
def TicksToUTC (t)
 

Function Documentation

◆ TicksNow()

def TicksNow ( )
    TicksNow() -> TTicks
    Get the current time in units of 'TTicks' (milliseconds).

◆ TicksToday()

def TicksToday ( )
    TicksToday() -> TTicks
    Get the time 0:00 of the current day in units of 'TTicks' (milliseconds).

◆ TicksOfDate()

def TicksOfDate (   dy,
  dm,
  dd 
)
    TicksOfDate(int dy, int dm, int dd) -> TTicks
    Convert a date into 'TTicks' units (absolute).

◆ TicksOfTime()

def TicksOfTime (   th,
  tm,
  ts 
)
    TicksOfTime(int th, int tm, int ts) -> TTicks
    Convert a time into 'TTicks' units (relative).

    The values returned by 'TicksOfDate' and 'TicksOfTime' as well as a
    number of milliseconds can be simply added to obtain a 'TTicks' value
    for a certain time at a certain date.

◆ TicksOfSeconds()

def TicksOfSeconds ( args)
    TicksOfSeconds(int secs) -> TTicks
    TicksOfSeconds(float secs) -> TTicks

◆ TicksOfMillis()

def TicksOfMillis (   ms)
TicksOfMillis(int ms) -> TTicks

◆ TicksAbsFromMonotic()

def TicksAbsFromMonotic (   tm)
TicksAbsFromMonotic(TTicks tm) -> TTicks

◆ TicksMonotonicFromAbs()

def TicksMonotonicFromAbs (   ta)
TicksMonotonicFromAbs(TTicks ta) -> TTicks

◆ TicksAbsStr()

def TicksAbsStr (   ticks)
Return an absolute TTicks value as a string in Home2L format.

◆ TicksRelStr()

def TicksRelStr (   ticks)
Return a relative TTicks value as a string in Home2L format.

◆ TicksAbsOf()

def TicksAbsOf (   something)
Magic wand to convert anything to an absolute TTicks value as intuitively as possible.
The function is similar to TicksRelOf(), but it guarantees to return an absolute time.

- Values of type string are interpreted as time specifications for TicksFromString()
  or as accepted by the Home2L Shell. The returned value is always an absolute time.

- Numeral types (int, float) are interpreted relative to now if their value is below 10^11
  (approx. 3 years). Otherwise, they are returned as they are.

- Values of type 'datetime.date' or 'datetime.datetime' are interpreted as absolute
  times and returned.

- Values of type 'datetime.time', are interpreted relative to today.
  Note: Be careful when calling this variant close to midnight. Functions triggered by
  the '/local/timer/daily' resource or the '@daily()' decorator are guaranteed to be called
  (shortly) after midnight and can thus safely use this variant.

- For values of type 'datetime.timedelta', the time relative to now is returned.

◆ TicksRelOf()

def TicksRelOf (   something)
Magic wand to convert anything to a relative 'TTicks' value as intuitively as possible.
The function is similar to TicksAbsOf(), but it guarantees to return a relative time.

- Values of type string are interpreted as time specifications for TicksFromString()
  or as accepted by the Home2L Shell.

- Values of numeral types are returned as they are.

- For values of type 'datetime.time', the relative time from the beginning of a day
  is returned.

- For values of type 'datetime.timedelta', the relative delta time in milliseconds
  is returned.

Note: Values of type 'datetime.date' or 'datetime.datetime' are not supported.

◆ TicksToPyDateTime()

def TicksToPyDateTime (   t)
Return a Python 'datetime.datetime' object for an absolute ticks value.

◆ TicksToPyTimeDelta()

def TicksToPyTimeDelta (   t)
Return a Python 'datetime.timedelta' object for a relative ticks value.

◆ TicksFromUTC()

def TicksFromUTC (   t)
Correct an absolute ticks value created from a UTC time string.

◆ TicksToUTC()

def TicksToUTC (   t)
Convert an absolute ticks value to a value that will return UTC time when converted to a string.