JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 24
  • Score
    100M100P100Q50761F
  • License MIT

Utilities for obtaining weather and astronomy forecast data.

Package Exports

  • @angelrove/forecast-utils

Readme

Modules

Astronomy
Astronomy/MoonCalc

MoonCalc for calculating moon times, positions, and phases.

import { MoonCalc } from ...

Importante!: ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'

Astronomy/SunCalc

SunCalc for calculating solar times, positions, and phases.

import { SunCalc } from ...

Importante: ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()' Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la localización dada.

Geolocation
OpenMeteo
Utils

Astronomy


Astronomy.exports.timeString([date], [sec]) ⇒ string

Formatea una fecha a un string legible.

Kind: static method of Astronomy
Returns: string - La fecha formateada.

Param Type Default
[date] Date
[sec] boolean false

Astronomy.exports.nowString(sec) ⇒ String

Kind: static method of Astronomy

Param Type
sec boolean

Astronomy.exports.dateFormat([date]) ⇒ string

Formatea una fecha a un string legible.

Kind: static method of Astronomy
Returns: string - La fecha formateada.

Param Type Default Description
[date] Date new Date() La fecha a formatear.

Astronomy.exports.getLocalTimeFromTz(timeZone, [date]) ⇒ string

Get local time from timezone

Kind: static method of Astronomy
Returns: string - - The formatted local time string.

Param Type Default Description
timeZone string The timezone string (e.g., 'America/New_York').
[date] Date | number new Date() The date object to format. Defaults to the current date.

Astronomy.exports.getLocalTimeInfo(apiKey, lat, lng) ⇒ Promise.<(any|LocalTimeData)>

Get local time from any location using Google Maps TimeZone API.

Kind: static method of Astronomy
Returns: Promise.<(any|LocalTimeData)> - - An object containing the local time and timezone information:
Throws:

  • Error - If the API request fails or returns an error status.
Param Type Description
apiKey string GoogleMaps API key.
lat number
lng number

Astronomy.AstroPosition : Object

Kind: static typedef of Astronomy
Properties

Name Type
altitude number
azimuth number
direction string
direction_full string

Astronomy.LocalTimeData : Object

Kind: static typedef of Astronomy
Properties

Name Type Description
time Date The local time.
timeStr string The formatted local time string.
timezone string The timezone name.
timezoneId string The timezone ID.
offset number The UTC offset in hours.
offsetSign string The sign of the offset ('+' or '-').
dstOffset number The DST offset in hours.

Astronomy/MoonCalc

MoonCalc for calculating moon times, positions, and phases.

import { MoonCalc } from ...

Importante!: ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()'


Astronomy/MoonCalc.phasesES : Object.<string, string>

Mapa de fases lunares. { phaseId, phaseName }

Kind: static constant of Astronomy/MoonCalc


Astronomy/MoonCalc.data(latitude, longitude, [date], [language]) ⇒ MoonData

Kind: static method of Astronomy/MoonCalc

Param Type Default
latitude number
longitude number
[date] Date new Date()
[language] string "es-ES"

Astronomy/MoonCalc.dataExt(latitude, longitude, [date], [language]) ⇒ Object

Información de la luna para una fecha y hora dadas. La fecha y hora se devolverán en la zona horaria local.

Kind: static method of Astronomy/MoonCalc

Param Type Default
latitude number
longitude number
[date] Date new Date()
[language] string "es-ES"

Astronomy/MoonCalc.emoji(latitude, longitude, [date]) ⇒ string

Kind: static method of Astronomy/MoonCalc
Returns: string - - Emoji of the moon phase

Param Type Default
latitude number
longitude number
[date] Date new Date()

Astronomy/MoonCalc.times(latitude, longitude, timezoneId, date) ⇒ Object

Kind: static method of Astronomy/MoonCalc

Param Type
latitude number
longitude number
timezoneId string
date Date

Astronomy/MoonCalc.getUpOrDown(altitude, highest) ⇒ string

Kind: static method of Astronomy/MoonCalc
Returns: string - - Up or down emoji

Param Type
altitude number
highest Date

Astronomy/MoonCalc.MoonData : Object

Kind: static typedef of Astronomy/MoonCalc
Properties

Name Type Description
position AstroPosition
next Object
next.newMoon string Date of the next new moon.
next.fullMoon string Date of the next full moon.

Astronomy/SunCalc

SunCalc for calculating solar times, positions, and phases.

import { SunCalc } from ...

Importante: ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()' Con excepción de 'getSolarTime()': recibe la hora local correspondiente a la localización dada.


Astronomy/SunCalc.all(date, latitude, longitude, timezoneId) ⇒ Object

Kind: static method of Astronomy/SunCalc

Param Type
date Date
latitude number
longitude number
timezoneId string

Astronomy/SunCalc.times(date, latitude, longitude, timezoneId) ⇒ Object

Kind: static method of Astronomy/SunCalc

Param Type
date Date
latitude number
longitude number
timezoneId string

Astronomy/SunCalc.getSolarTime(date, lng, offsetSign, offset) ⇒ string

Kind: static method of Astronomy/SunCalc
Returns: string - - Local time in "HH:mm" format

Param Type Description
date Date
lng number
offsetSign string "+" or "-"
offset number UTC offset in hours

Astronomy/SunCalc.position(latitude, longitude) ⇒ Object

Kind: static method of Astronomy/SunCalc

Param Type
latitude number
longitude number

Astronomy/SunCalc.getIsNight(lat, lon, timezoneId, date, dateStr) ⇒ boolean

Kind: static method of Astronomy/SunCalc
Returns: boolean - - true if it's night, false otherwise

Param Type
lat number
lon number
timezoneId string
date number | Date
dateStr string

Astronomy/SunCalc.getPhase(altitude, noon) ⇒ string

Kind: static method of Astronomy/SunCalc
Returns: string - - The phase of the sun based on its altitude

Param Type
altitude number
noon string

Geolocation


Geolocation.exports.getGeolocation() ⇒ Promise.<{latitude: number, longitude: number, formatted_address: string}>

Get the current geolocation of the device and reverse geocode it to get the address.

Kind: static method of Geolocation
Throws:

  • Error If geolocation is not supported or permission is denied.

OpenMeteo


OpenMeteo.exports.useForecastCurrent(lat, lon, refreshIntervalMin) ⇒ Object

Custom hook to fetch current weather data from OpenMeteo API.

Kind: static method of OpenMeteo

Param Type
lat number
lon number
refreshIntervalMin number

OpenMeteo.exports.useForecastDaily(lat, lon, refreshIntervalMin) ⇒ Object

Custom hook to fetch daily forecast (10 days) data from OpenMeteo API. https://api.open-meteo.com/v1/forecast?timezone=auto&latitude=36.6644363&longitude=-4.5108962&forecast_days=10&daily=weathercode

Kind: static method of OpenMeteo

Param Type
lat number
lon number
refreshIntervalMin number

OpenMeteo.exports.useForecastHourly(location, dayNum) ⇒ Object

Custom hook to fetch hourly forecast data for a given location and number of days from OpenMeteo API.

Kind: static method of OpenMeteo

Param Type Description
location Object
dayNum number Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ...

OpenMeteo.exports.weatherSymbol(code, [precipitation], night, dark) ⇒ Object

Get weather symbol and description based on the weather code.

Kind: static method of OpenMeteo

Param Type
code any
[precipitation] number
night boolean
dark boolean

Utils


Utils.directions : Array.<Compass>

English compass designations

Kind: static constant of Utils
Properties

Name Type Description
short string Short compass designation
full string Full compass designation

Utils.directionsEs : Array.<Compass>

Spanish compass designations

Kind: static constant of Utils
Properties

Name Type Description
short string Short compass designation
full string Full compass designation

Utils.ALERT_LEVEL : Array.<AlertLevel>

Alert levels for rain and showers

Kind: static constant of Utils


Utils.WIND_LEVELS : Array.<WindLevel>

Ordered list of wind levels.

Kind: static constant of Utils


Utils.exports.degreesToCompass(degrees, language) ⇒ Object

Convert degrees to compass designation

Kind: static method of Utils

Param Type Description
degrees number
language string Language code ("en-US", "es-ES", "auto")

Utils.exports.getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒ Object | null

Get warning by today and tomorrow

Kind: static method of Utils

Param Type
precipitationSumToday number
precipitationSumTomorrow number
showersSumToday number
showersSumTomorrow number

Utils.exports.getWarning(precipitation, showers) ⇒ Object | null

Get warning by precipitation and showers

Kind: static method of Utils

Param Type
precipitation number
showers number

Utils.exports.windArrowTx(deg)

Convert wind direction in degrees to an arrow representation.

Kind: static method of Utils

Param Type Description
deg number Wind direction in degrees.

Utils.exports.getWindLevel(speed) ⇒ WindLevel | null

Return the wind level based on the speed.

Kind: static method of Utils
Returns: WindLevel | null - Wind level object or null if speed is null

Param Type Description
speed number Wind speed in km/h

Utils.Compass : Object

Kind: static typedef of Utils
Properties

Name Type Description
short string Short compass designation
full string Full compass designation

Utils.AlertLevel : Object

Kind: static typedef of Utils
Properties

Name Type Description
levelNum number The alert level number.
level string The alert level string (e.g., "red", "orange", "yellow").
precipitation number The precipitation threshold for the alert level.
showers number The showers threshold for the alert level.

Utils.WindLevel : Object

Kind: static typedef of Utils
Properties

Name Type Description
id number Level ID
speed number Minimum wind speed for this level
color string Color representing this level
tx string Text representing this level
txEn string Text representing this level