Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro committed Jul 23, 2019
1 parent ab19ca6 commit 078dc5a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
leaflet/
libs/
20 changes: 18 additions & 2 deletions js/localweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function getWeatherInfo(lat, lon) {
let sunrise_time = `${sunrise_hr}:${sunrise_mn} AM`;

let sunset = new Date(data.sys.sunset * 1000);
let sunset_hr = sunset.getHours() > 12 ? sunset.getHours() - 12: sunset.getHours();
let sunset_hr = sunset.getHours() % 12;
let sunset_mn = sunset.getMinutes();
let sunset_time = `${sunset_hr}:${sunset_mn} PM`;

Expand All @@ -69,7 +69,23 @@ async function getWeatherInfo(lat, lon) {
}

function displayWeather(loc, icon, weather, temp, sunrise, sunset, wind) {
$("#dspDateTime").html(`${new Date().toLocaleString()}`);
const timestamp = new Date(Date.now());
let YYYY = timestamp.getFullYear();
let MM = timestamp.getMonth() + 1;
MM = MM < 10 ? "0" + MM : MM;
let DD = timestamp.getDate();
DD = DD < 10 ? "0" + DD : DD;

let HH = timestamp.getHours();
let ampm = HH >= 12 ? "PM" : "AM"
HH = HH > 12 ? HH % 12 : HH;
let mm = timestamp.getMinutes();
mm = mm < 10 ? "0" + mm : mm;
let ss = timestamp.getSeconds();
ss = ss < 10 ? "0" + ss : ss;

// $("#dspDateTime").html(`${new Date().toLocaleString()}`);
$("#dspDateTime").html(`${YYYY}-${MM}-${DD} ${HH}:${mm}:${ss} ${ampm}`);
$("#dspLoc").css({'margin-bottom': '-.75rem'});
$("#dspLoc").html(loc);
$('.dspIcon').css({'display': 'inline'});
Expand Down

0 comments on commit 078dc5a

Please sign in to comment.