PIconnect.time module

PIconnect.time.timestamp_to_index(timestamp)

Convert AFTime object to datetime in local timezone.

Parameters

timestamp (System.DateTime) – Timestamp in .NET format to convert to datetime.

Returns

Datetime with the timezone info from PIConfig.DEFAULT_TIMEZONE.

Return type

datetime

PIconnect.time.to_af_time(time)

Convert a time to a AFTime value.

Parameters

time (str | datetime) – Time to convert to AFTime.

Returns

Time range covered by the start and end time.

Return type

AF.Time.AFTime

PIconnect.time.to_af_time_range(start_time, end_time)

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
  • start_time (str | datetime) – Start time of the time range.

  • end_time (str | datetime) – End time of the time range.

Returns

Time range covered by the start and end time.

Return type

AF.Time.AFTimeRange