Socket
Socket
Sign inDemoInstall

ec-weather-js

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

CONTRIBUTING.md

2

package.json
{
"name": "ec-weather-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Javascript API for Environment Canada Weather Data",

@@ -5,0 +5,0 @@ "main": "Weather.js",

@@ -73,3 +73,3 @@ /**

}
}
};
const result = recurse(this.data);

@@ -107,3 +107,3 @@ return new Parse(result);

}
}
};
const result = recurse(this.data);

@@ -110,0 +110,0 @@ return new Parse(result);

@@ -21,3 +21,3 @@ /**

constructor(fetchedXMLWeatherData) {
if (!fetchedXMLWeatherData) throw new TypeError('Constructor must be passed weather data from Environment Canada.')
if (!fetchedXMLWeatherData) throw new TypeError('Constructor must be passed weather data from Environment Canada.');
if (typeof fetchedXMLWeatherData !== 'string') throw new TypeError('Argument must be a string.');

@@ -71,5 +71,5 @@

if (date instanceof Date) {
const utcTimestamp = makeUTCTimestamp(date);
const utcTimestamp = this._makeUTCTimestamp(date);
// Retreive the value if the date stamp is a key
// Retreive the value if the timestamp is a key
if (forecastData.has(utcTimestamp)) {

@@ -106,3 +106,3 @@ return forecastData.get(utcTimestamp);

// and if the hour is at night, add 'night'
const weekday = (localDateHour >= 6 && localDateHour < 18) ? getWeekDay(localDate) : getWeekDay(localDate) + ' night';
const weekday = (localDateHour >= 6 && localDateHour < 18) ? this._getWeekDay(localDate) : this._getWeekDay(localDate) + ' night';
// retrieve the forecast for that day of the week.

@@ -117,46 +117,46 @@ return forecastData.get(weekday);

}
}
/**
* Helper function.
* Turns a Date instance into a UTC Timestamp compatible with Environment Canada's weather data.
* @param {<Date>} date The date to forecast.
* @returns {string} The UTC Timestamp.
*/
function makeUTCTimestamp(date) {
const year = date.getUTCFullYear().toString();
let month = date.getUTCMonth() + 1;
month = month.toString();
if (month.length < 2) month = '0' + month;
let day = date.getUTCDate().toString();
if (day.length < 2) day = '0' + day;
let hour = date.getUTCHours().toString();
if (hour.length < 2) hour = '0' + hour;
return year + month + day + hour + '00';
/**
* Helper method.
* Turns a Date instance into a UTC Timestamp compatible with Environment Canada's weather data.
* @param {<Date>} date The date to forecast.
* @returns {string} The UTC Timestamp.
*/
_makeUTCTimestamp(date) {
const year = date.getUTCFullYear().toString();
let month = date.getUTCMonth() + 1;
month = month.toString();
if (month.length < 2) month = '0' + month;
let day = date.getUTCDate().toString();
if (day.length < 2) day = '0' + day;
let hour = date.getUTCHours().toString();
if (hour.length < 2) hour = '0' + hour;
return year + month + day + hour + '00';
}
/**
* Helper method.
* Expands the abbreviated weekday text returned from a Date object.
* @param {<Date>} date The localized date to forecast.
* @returns {string} Full weekday name.
*/
_getWeekDay(date) {
const partial = date.toUTCString().slice(0, 3);
const days = new Map([
[ 'sun', 'sunday' ],
[ 'mon', 'monday' ],
[ 'tue', 'tuesday' ],
[ 'wed', 'wednesday' ],
[ 'thu', 'thursday' ],
[ 'fri', 'friday' ],
[ 'sat', 'saturday' ]
]);
return days.get(partial.toLowerCase());
}
}
/**
* Helper function.
* Expands the abbreviated weekday text returned from a Date object.
* @param {<Date>} date The localized date to forecast.
* @returns {string} Full weekday name.
*/
function getWeekDay(date) {
const partial = date.toUTCString().slice(0, 3);
const days = new Map([
[ 'sun', 'sunday' ],
[ 'mon', 'monday' ],
[ 'tue', 'tuesday' ],
[ 'wed', 'wednesday' ],
[ 'thu', 'thursday' ],
[ 'fri', 'friday' ],
[ 'sat', 'saturday' ]
]);
return days.get(partial.toLowerCase());
}
module.exports = Weather;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc