forked from Hugovdberg/PIconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cd459a
commit 8bb7429
Showing
2 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from datetime import datetime | ||
from typing import Union | ||
|
||
from PIconnect.AFSDK import AF | ||
|
||
|
||
def to_af_time_range(start_time: Union[str, datetime], end_time: Union[str, datetime]): | ||
"""to_af_time_range | ||
Return AF.Time.AFTimeRange object from datetime or string | ||
using :afsdk:`AF.Time.AFTimeRange <M_OSIsoft_AF_Time_AFTimeRange__ctor_1.htm>`. | ||
If string is used, it is assumed that user knows the format | ||
that should be passed to AF.Time.AFTimeRange. | ||
""" | ||
|
||
if isinstance(start_time, datetime): | ||
start_time = start_time.isoformat() | ||
if isinstance(end_time, datetime): | ||
end_time = end_time.isoformat() | ||
|
||
return AF.Time.AFTimeRange(start_time, end_time) |