projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved datetime parsing for unit.py
[osm/N2VC.git]
/
juju
/
unit.py
diff --git
a/juju/unit.py
b/juju/unit.py
index
cad4bb7
..
dc5fa63
100644
(file)
--- a/
juju/unit.py
+++ b/
juju/unit.py
@@
-1,5
+1,6
@@
import logging
import logging
-from datetime import datetime
+
+from dateutil.parser import parse as parse_date
from . import model
from .client import client
from . import model
from .client import client
@@
-20,10
+21,7
@@
class Unit(model.ModelEntity):
"""Get the time when the `agent_status` was last updated.
"""
"""Get the time when the `agent_status` was last updated.
"""
- since = self.data['agent-status']['since']
- # Juju gives us nanoseconds, but Python only supports microseconds
- since = since[:26]
- return datetime.strptime(since, "%Y-%m-%dT%H:%M:%S.%f")
+ return parse_date(self.data['agent-status']['since'])
@property
def agent_status_message(self):
@property
def agent_status_message(self):
@@
-44,10
+42,7
@@
class Unit(model.ModelEntity):
"""Get the time when the `workload_status` was last updated.
"""
"""Get the time when the `workload_status` was last updated.
"""
- since = self.data['workload-status']['since']
- # Juju gives us nanoseconds, but Python only supports microseconds
- since = since[:26]
- return datetime.strptime(since, "%Y-%m-%dT%H:%M:%S.%f")
+ return parse_date(self.data['workload-status']['since'])
@property
def workload_status_message(self):
@property
def workload_status_message(self):