display time if available

develop
Kenneth Barbour 2020-07-09 21:23:00 -04:00
parent 68efbe3410
commit cb53a49210
2 changed files with 2 additions and 1 deletions

View File

@ -61,7 +61,7 @@ server = http.createServer(function(req, res) {
if (pathname === "/weather/current") {
res.writeHead(200, {'Content-Type': 'application/json'});
res.write(JSON.stringify({
"time": new Date(),
"time": Math.floor(new Date().getTime()/1000),
"temperature": 24,
"pressure": 101361.7,
"humidity": 55,

View File

@ -73,6 +73,7 @@ class CurrentConditions {
return (
<Layout>
<h1 class="title">Current Conditions</h1>
{Weather.current.time && (<h2 class="subtitle">as of {new Date(Weather.current.time*1000).toLocaleString()}</h2>)}
<MeasurementList>
<Measurement title="Temperature" value={localeTemperature(Weather.current.temperature)} />
<Measurement title="Feels like" value={localeTemperature(feelsLike(Weather.current.temperature, Weather.current.humidity))} />