'use strict'; // // this file contains just the implementation of the // Observation class (I know there are no classes in javascript...) // function Observation(obj) { if (typeof(obj)!='object') throw new Error("Observation object can only be constructed using an object."); if (!obj.date) throw new Error("Observation object must have a 'date' parameter"); var ret = []; // FIXME: Check transisiton from summer- and winter-time!! var utc = obj.date.toString().toUpperCase()=="NOW" ? new Date() : new Date(obj.date); if (isNaN(utc.valueOf())) throw new Error('"'+obj.date+'" not a valid Date... try something like "2013-01-08 23:05 UTC".'); ret.start = utc; ret.id = obj.id; // If the given data is not an array, make it the first entry of an array // so that we can simply loop over all entries if (obj.measurements.length===undefined) { var cpy = obj.measurements; obj.measurements = []; obj.measurements[0] = cpy; } for (var i=0; i