Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
iCity
EnergyDashboard
Commits
bee78fb8
Commit
bee78fb8
authored
3 years ago
by
Pithon Kabiro
Browse files
Options
Download
Email Patches
Plain Diff
New function: calculate index of end timestamp
parent
d159d439
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/js/src_modules/aggregateHelpers.mjs
+30
-2
public/js/src_modules/aggregateHelpers.mjs
with
30 additions
and
2 deletions
+30
-2
public/js/src_modules/aggregateHelpers.mjs
+
30
-
2
View file @
bee78fb8
...
@@ -93,6 +93,34 @@ const getIndexOfStartTimestamp = function (
...
@@ -93,6 +93,34 @@ const getIndexOfStartTimestamp = function (
}
}
};
};
/**
* Calculate the index of an end timestamp in an array of timestamps
*
* @param {Array} inputTimestampArr An array of timestamps, extracted from an array of observations
* @param {String} timestampOfInterest A string representing the timestamp of interest in ISO 8601 format
* @returns {Number} An integer representing the index of the timestamp of interest in the array of timestamps
*/
const
getIndexOfEndTimestamp
=
function
(
inputTimestampArr
,
timestampOfInterest
)
{
const
timestampEndIndex
=
getIndexOfTimestamp
(
inputTimestampArr
,
timestampOfInterest
);
// If the timestamp does not exist in the timestamp array
if
(
timestampEndIndex
===
-
1
)
{
throw
new
Error
(
"
An end timestamp could not be found in the timestamp array
"
);
}
// If the timestamp exists in the timestamp array
else
{
return
timestampEndIndex
;
}
};
/**
/**
* Calculate the indexes of the start and end timestamps
* Calculate the indexes of the start and end timestamps
* @param {Array} obsTimestampArr An array of observations timestamps
* @param {Array} obsTimestampArr An array of observations timestamps
...
@@ -122,11 +150,11 @@ const calculateIndexStartEndTimestamp = function (
...
@@ -122,11 +150,11 @@ const calculateIndexStartEndTimestamp = function (
);
);
// Calculate the indexes of the timestamps for the start and end of interval
// Calculate the indexes of the timestamps for the start and end of interval
const
indexStartTimestamp
=
getIndexOfTimestamp
(
const
indexStartTimestamp
=
getIndexOf
Start
Timestamp
(
obsTimestampArr
,
obsTimestampArr
,
startIso8601DateTimeString
startIso8601DateTimeString
);
);
const
indexEndTimestamp
=
getIndexOfTimestamp
(
const
indexEndTimestamp
=
getIndexOf
End
Timestamp
(
obsTimestampArr
,
obsTimestampArr
,
endIso8601DateTimeString
endIso8601DateTimeString
);
);
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets