Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
LabPlot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
LabPlot
Commits
9eec1a07
Commit
9eec1a07
authored
Jul 23, 2017
by
Stefan Gerlach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix converting double to date time and vice versa
parent
3fcfdabf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
src/backend/core/datatypes/DateTime2DoubleFilter.h
src/backend/core/datatypes/DateTime2DoubleFilter.h
+6
-5
src/backend/core/datatypes/Double2DateTimeFilter.h
src/backend/core/datatypes/Double2DateTimeFilter.h
+5
-4
No files found.
src/backend/core/datatypes/DateTime2DoubleFilter.h
View file @
9eec1a07
...
...
@@ -40,10 +40,11 @@ class DateTime2DoubleFilter : public AbstractSimpleFilter {
public:
virtual
double
valueAt
(
int
row
)
const
{
if
(
!
m_inputs
.
value
(
0
))
return
NAN
;
QDateTime
input_value
=
m_inputs
.
value
(
0
)
->
dateTimeAt
(
row
);
if
(
!
input_value
.
isValid
())
return
NAN
;
return
double
(
input_value
.
date
().
toJulianDay
())
+
double
(
-
input_value
.
time
().
msecsTo
(
QTime
(
12
,
0
,
0
,
0
))
)
/
86400000.0
;
QDateTime
inputDate
=
m_inputs
.
value
(
0
)
->
dateTimeAt
(
row
);
if
(
!
inputDate
.
isValid
())
return
NAN
;
QDateTime
start
(
QDate
(
1900
,
1
,
1
));
return
double
(
start
.
daysTo
(
inputDate
))
+
double
(
-
inputDate
.
time
().
msecsTo
(
QTime
(
0
,
0
,
0
,
0
))
)
/
86400000.0
;
}
//! Return the data type of the column
...
...
@@ -51,7 +52,7 @@ public:
protected:
//! Using typed ports: only DateTime inputs are accepted.
virtual
bool
inputAcceptable
(
int
,
const
AbstractColumn
*
source
)
{
virtual
bool
inputAcceptable
(
int
,
const
AbstractColumn
*
source
)
{
return
source
->
columnMode
()
==
AbstractColumn
::
DateTime
;
}
};
...
...
src/backend/core/datatypes/Double2DateTimeFilter.h
View file @
9eec1a07
...
...
@@ -43,15 +43,16 @@ public:
if
(
!
m_inputs
.
value
(
0
))
return
QDate
();
double
inputValue
=
m_inputs
.
value
(
0
)
->
valueAt
(
row
);
if
(
std
::
isnan
(
inputValue
))
return
QDate
();
return
QDate
::
fromJulianDay
(
qRound
(
inputValue
));
//QDEBUG(" convert " << inputValue << " to " << QDate(1900, 1, int(inputValue)));
return
QDate
(
1900
,
1
,
1
+
int
(
inputValue
));
}
virtual
QTime
timeAt
(
int
row
)
const
{
if
(
!
m_inputs
.
value
(
0
))
return
QTime
();
double
inputValue
=
m_inputs
.
value
(
0
)
->
valueAt
(
row
);
if
(
std
::
isnan
(
inputValue
))
return
QTime
();
// we only want the digits behind the dot and
//
convert them from fraction of day to milliseconds
return
QTime
(
12
,
0
,
0
,
0
).
addMSecs
(
int
(
(
inputValue
-
int
(
inputValue
))
*
86400000.0
));
// we only want the digits behind the dot and
convert them from fraction of day to milliseconds
//
QDEBUG(" convert " << inputValue << " to " << QTime(0,0,0,0).addMSecs(int( (inputValue - int(inputValue)) * 86400000.0 )));
return
QTime
(
0
,
0
,
0
,
0
).
addMSecs
(
int
(
(
inputValue
-
int
(
inputValue
))
*
86400000.0
));
}
virtual
QDateTime
dateTimeAt
(
int
row
)
const
{
return
QDateTime
(
dateAt
(
row
),
timeAt
(
row
));
...
...
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