Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
9ebe0c3a
Commit
9ebe0c3a
authored
Sep 22, 2014
by
Saul Ibarra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use timezone aware timestamps for call history
parent
7361426c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
history.py
blink/history.py
+12
-10
No files found.
blink/history.py
View file @
9ebe0c3a
...
@@ -12,12 +12,13 @@ from PyQt4.QtGui import QIcon
...
@@ -12,12 +12,13 @@ from PyQt4.QtGui import QIcon
from
application.notification
import
IObserver
,
NotificationCenter
from
application.notification
import
IObserver
,
NotificationCenter
from
application.python
import
Null
from
application.python
import
Null
from
application.python.types
import
Singleton
from
application.python.types
import
Singleton
from
date
time
import
date
,
datetime
from
date
util.tz
import
tzlocal
from
zope.interface
import
implements
from
zope.interface
import
implements
from
sipsimple.account
import
BonjourAccount
from
sipsimple.account
import
BonjourAccount
from
sipsimple.addressbook
import
AddressbookManager
from
sipsimple.addressbook
import
AddressbookManager
from
sipsimple.threading
import
run_in_thread
from
sipsimple.threading
import
run_in_thread
from
sipsimple.util
import
ISOTimestamp
from
blink.resources
import
ApplicationData
,
Resources
from
blink.resources
import
ApplicationData
,
Resources
from
blink.util
import
run_in_gui_thread
from
blink.util
import
run_in_gui_thread
...
@@ -32,7 +33,7 @@ class HistoryManager(object):
...
@@ -32,7 +33,7 @@ class HistoryManager(object):
def
__init__
(
self
):
def
__init__
(
self
):
try
:
try
:
data
=
pickle
.
load
(
open
(
ApplicationData
.
get
(
'calls_history'
)))
data
=
pickle
.
load
(
open
(
ApplicationData
.
get
(
'calls_history'
)))
if
not
isinstance
(
data
,
list
)
or
not
all
(
isinstance
(
item
,
HistoryEntry
)
and
item
.
text
for
item
in
data
):
if
not
isinstance
(
data
,
list
)
or
not
all
(
isinstance
(
item
,
HistoryEntry
)
and
item
.
text
and
isinstance
(
item
.
call_time
,
ISOTimestamp
)
for
item
in
data
):
raise
ValueError
(
"invalid save data"
)
raise
ValueError
(
"invalid save data"
)
except
Exception
:
except
Exception
:
self
.
calls
=
[]
self
.
calls
=
[]
...
@@ -147,19 +148,20 @@ class HistoryEntry(object):
...
@@ -147,19 +148,20 @@ class HistoryEntry(object):
def
text
(
self
):
def
text
(
self
):
result
=
unicode
(
self
.
name
or
self
.
uri
)
result
=
unicode
(
self
.
name
or
self
.
uri
)
if
self
.
call_time
:
if
self
.
call_time
:
call_date
=
self
.
call_time
.
date
()
call_time
=
self
.
call_time
.
astimezone
(
tzlocal
())
today
=
date
.
today
()
call_date
=
call_time
.
date
()
today
=
ISOTimestamp
.
now
()
.
date
()
days
=
(
today
-
call_date
)
.
days
days
=
(
today
-
call_date
)
.
days
if
call_date
==
today
:
if
call_date
==
today
:
result
+=
self
.
call_time
.
strftime
(
" at
%
H:
%
M"
)
result
+=
call_time
.
strftime
(
" at
%
H:
%
M"
)
elif
days
==
1
:
elif
days
==
1
:
result
+=
self
.
call_time
.
strftime
(
" Yesterday at
%
H:
%
M"
)
result
+=
call_time
.
strftime
(
" Yesterday at
%
H:
%
M"
)
elif
days
<
7
:
elif
days
<
7
:
result
+=
self
.
call_time
.
strftime
(
" on
%
A"
)
result
+=
call_time
.
strftime
(
" on
%
A"
)
elif
call_date
.
year
==
today
.
year
:
elif
call_date
.
year
==
today
.
year
:
result
+=
self
.
call_time
.
strftime
(
" on
%
B
%
d"
)
result
+=
call_time
.
strftime
(
" on
%
B
%
d"
)
else
:
else
:
result
+=
self
.
call_time
.
strftime
(
" on
%
Y-
%
m-
%
d"
)
result
+=
call_time
.
strftime
(
" on
%
Y-
%
m-
%
d"
)
if
self
.
duration
:
if
self
.
duration
:
seconds
=
int
(
self
.
duration
.
total_seconds
())
seconds
=
int
(
self
.
duration
.
total_seconds
())
if
seconds
>=
3600
:
if
seconds
>=
3600
:
...
@@ -175,7 +177,7 @@ class HistoryEntry(object):
...
@@ -175,7 +177,7 @@ class HistoryEntry(object):
if
session
.
start_time
is
None
and
session
.
end_time
is
not
None
:
if
session
.
start_time
is
None
and
session
.
end_time
is
not
None
:
# Session may have anded before it fully started
# Session may have anded before it fully started
session
.
start_time
=
session
.
end_time
session
.
start_time
=
session
.
end_time
call_time
=
session
.
start_time
or
datetime
.
now
()
call_time
=
session
.
start_time
or
ISOTimestamp
.
now
()
if
session
.
start_time
and
session
.
end_time
:
if
session
.
start_time
and
session
.
end_time
:
duration
=
session
.
end_time
-
session
.
start_time
duration
=
session
.
end_time
-
session
.
start_time
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment