Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KAlarm
Commits
26926867
Commit
26926867
authored
Sep 27, 2018
by
David Jarvie
Browse files
Add KADateTime::msecsTo()
parent
d9651915
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/kadatetime.cpp
View file @
26926867
...
...
@@ -1240,6 +1240,20 @@ KADateTime KADateTime::addYears(int years) const
return
result
;
}
qint64
KADateTime
::
msecsTo
(
const
KADateTime
&
t2
)
const
{
if
(
!
isValid
()
||
!
t2
.
isValid
())
return
0
;
if
(
d
->
dateOnly
())
{
const
QDate
dat
=
t2
.
d
->
dateOnly
()
?
t2
.
d
->
date
()
:
t2
.
toTimeSpec
(
d
->
spec
()).
d
->
date
();
return
d
->
date
().
daysTo
(
dat
)
*
86400
*
1000
;
}
if
(
t2
.
d
->
dateOnly
())
return
toTimeSpec
(
t2
.
d
->
spec
()).
d
->
date
().
daysTo
(
t2
.
d
->
date
())
*
86400
*
1000
;
QTimeZone
local
;
return
d
->
toUtc
(
local
).
msecsTo
(
t2
.
d
->
toUtc
(
local
));
}
qint64
KADateTime
::
secsTo
(
const
KADateTime
&
t2
)
const
{
if
(
!
isValid
()
||
!
t2
.
isValid
())
...
...
src/kadatetime.h
View file @
26926867
...
...
@@ -921,6 +921,27 @@ public:
*/
KADateTime
addYears
(
int
years
)
const
;
/**
* Returns the number of milliseconds from this date/time to the @p other date/time.
*
* Before performing the comparison, the two date/times are converted to UTC
* to ensure that the result is correct if one of the two date/times has
* daylight saving time (DST) and the other doesn't.
*
* If one instance is date-only and the other is date-time, the date-time
* value is first converted to the same time specification as the date-only
* value, and the result is the difference in days between the resultant
* date and the date-only date.
*
* If both instances are date-only, the result is the difference in days
* between the two dates, ignoring time zones.
*
* @param other other date/time
* @return number of milliseconds difference
* @see addSecs(), daysTo()
*/
qint64
msecsTo
(
const
KADateTime
&
other
)
const
;
/**
* Returns the number of seconds from this date/time to the @p other date/time.
*
...
...
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