PIconnect.Time module#

Time related functions and classes.

PIconnect.Time.timestamp_to_index(timestamp: DateTime) datetime#

Convert AFTime object to datetime in local timezone.

Parameters:

(System.DateTime) (timestamp)

Return type:

datetime: Datetime with the timezone info from PIConfig.DEFAULT_TIMEZONE.

PIconnect.Time.to_af_time(time: str | datetime) AFTime#

Convert a time to a AFTime value.

Parameters:

datetime) (time (str |)

Returns:

AFTime version of time.

Return type:

AF.Time.AFTime

PIconnect.Time.to_af_time_range(start_time: str | datetime, end_time: str | datetime) AFTimeRange#

Convert a combination of start and end time to a time range.

Both start_time and end_time can be either a datetime.datetime object or a string. datetime objects are first converted to a string, before being passed to AF.Time.AFTimeRange. It is also possible to specify either end as a datetime object, and then specify the other boundary as a relative string.

Parameters:
  • datetime) (end_time (str |)

  • datetime)

Returns:

Time range covered by the start and end time.

Return type:

AF.Time.AFTimeRange

PIconnect.Time.to_af_time_span(interval: str | timedelta | Timedelta | None) AFTimeSpan#

Convert a time interval to a AFTimeSpan value.

Parameters:

pd.Timedelta) (interval (str | datetime.timedelta |)

Returns:

AFTimeSpan version of interval.

Return type:

AF.Time.AFTimeSpan