Skip to content

Commit

Permalink
Merge pull request #38 from lwindg/develop
Browse files Browse the repository at this point in the history
2.1.2
  • Loading branch information
taotao authored May 2, 2017
2 parents 0d1c592 + 36ff082 commit 251d3c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 6 additions & 0 deletions build-deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sanji-bundle-time (2.1.2-1) unstable; urgency=low

* fix: Update time with seconds & ns.

-- Aeluin Chen <[email protected]> Fri, 21 Apr 2017 00:01:15 +0800

sanji-bundle-time (2.1.1-1) unstable; urgency=low

* fix: Sync time at startup.
Expand Down
2 changes: 1 addition & 1 deletion bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "time",
"version": "2.1.1",
"version": "2.1.2",
"author": "Zack YL Shih",
"email": "[email protected]",
"description": "Provides the system-time management function",
Expand Down
6 changes: 2 additions & 4 deletions systime/systime.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ def set_system_time(time_string):
"""
rc = None
try:
dateTimeString = datetime\
.strptime(time_string, "%Y-%m-%dT%H:%M:%S.%fZ")\
.strftime("%m%d%H%M%Y")
datetime.strptime(time_string, "%Y-%m-%dT%H:%M:%S.%fZ")

except ValueError:
raise ValueError('Time format error.')

else:
rc = subprocess.call(
"date --utc %s; hwclock -w" % dateTimeString, shell=True)
"date --set=\"%s\"; hwclock -w" % time_string, shell=True)

return True if rc == 0 else False

Expand Down
3 changes: 1 addition & 2 deletions tests/test_systime/test_systime.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def test_set_system_time(self):
# case 1: command success
subprocess.call.return_value = 0
t = "2015-03-26T16:27:48.611441Z"
ans_t = "032616272015"
self.assertTrue(SysTime.set_system_time(t))
subprocess.call.assert_called_with(
"date --utc %s; hwclock -w" % ans_t, shell=True)
"date --set=\"%s\"; hwclock -w" % t, shell=True)

# case 2: command failed
subprocess.call.return_value = 1
Expand Down

0 comments on commit 251d3c9

Please sign in to comment.