mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 05:06:39 +01:00
Update get_dayahead.js
This commit is contained in:
@@ -81,15 +81,18 @@ function doGet(e) {
|
|||||||
|
|
||||||
if (period) {
|
if (period) {
|
||||||
var startTime = period.getChild('timeInterval').getChildText('start');
|
var startTime = period.getChild('timeInterval').getChildText('start');
|
||||||
|
var resolution = period.getChildText('resolution');
|
||||||
|
var stepSeconds = resolution === "PT15M" ? 900 : 3600;
|
||||||
|
logger("Resolution: " + resolution + " (" + stepSeconds + " seconds per step)");
|
||||||
logger(startTime);
|
logger(startTime);
|
||||||
var points = period.getChildren('Point');
|
var points = period.getChildren('Point');
|
||||||
|
|
||||||
for (var i = 0; i < points.length; i++) {
|
for (var i = 0; i < points.length; i++) {
|
||||||
var position = points[i].getChildText('position');
|
var position = parseInt(points[i].getChildText('position'), 10);
|
||||||
var priceAmount = points[i].getChildText('price.amount') * factor;
|
var priceAmount = points[i].getChildText('price.amount') * factor;
|
||||||
|
|
||||||
// Convert ISO date to epoch time (in seconds)
|
// Convert ISO date to epoch time (in seconds)
|
||||||
var epochTime = new Date(startTime).getTime() / 1000 + (position - 1) * 3600;
|
var epochTime = new Date(startTime).getTime() / 1000 + (position - 1) * stepSeconds;
|
||||||
|
|
||||||
jsonData.push({
|
jsonData.push({
|
||||||
time: epochTime,
|
time: epochTime,
|
||||||
|
|||||||
Reference in New Issue
Block a user