Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
da145bdd
Commit
da145bdd
authored
Nov 17, 2014
by
Mitchell Rosen
Browse files
fix localization in time strings
parent
7aff20b4
Changes
1
Show whitespace changes
Inline
Side-by-side
cockatrice/src/gamesmodel.cpp
View file @
da145bdd
...
...
@@ -10,7 +10,6 @@ namespace {
const
unsigned
SECS_PER_MIN
=
60
;
const
unsigned
SECS_PER_HALF_HOUR
=
1600
;
// 60 * 30
const
unsigned
SECS_PER_HOUR
=
3600
;
// 60 * 60
const
unsigned
SECS_PER_DAY
=
86400
;
// 60 * 60 * 24
/**
* Pretty print an integer number of seconds ago. Accurate to only one unit,
...
...
@@ -24,28 +23,22 @@ namespace {
* an accurate timestamp of day old games.
*/
QString
prettyPrintSecsAgo
(
uint32_t
secs
)
{
std
::
ostringstream
str_stream
;
if
(
secs
<
SECS_PER_MIN
)
{
str_stream
<<
secs
;
str_stream
<<
"s ago"
;
}
else
if
(
secs
<
SECS_PER_HOUR
)
{
return
QString
::
number
(
secs
).
append
(
QObject
::
tr
(
"s ago"
))
;
}
if
(
secs
<
SECS_PER_HOUR
)
{
uint32_t
mins
=
secs
/
SECS_PER_MIN
;
if
(
secs
%
SECS_PER_MIN
>=
SECS_PER_HALF_MIN
)
mins
++
;
str_stream
<<
mins
;
str_stream
<<
"m ago"
;
}
else
if
(
secs
<
SECS_PER_HOUR
*
5
)
{
return
QString
::
number
(
mins
).
append
(
QObject
::
tr
(
"m ago"
))
;
}
if
(
secs
<
SECS_PER_HOUR
*
5
)
{
uint32_t
hours
=
secs
/
SECS_PER_HOUR
;
if
(
secs
%
SECS_PER_HOUR
>=
SECS_PER_HALF_HOUR
)
hours
++
;
str_stream
<<
hours
;
str_stream
<<
"hr ago"
;
}
else
{
str_stream
<<
"5+ hours ago"
;
return
QString
::
number
(
hours
).
append
(
QObject
::
tr
(
"hr ago"
));
}
return
QObject
::
tr
(
str_stream
.
str
().
c_str
());
return
QObject
::
tr
(
"5+ hours ago"
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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