Package Exports
- @angelrove/forecast-utils
Readme
Modules
- MoonCalc
MoonCalc for calculating moon times, positions, and phases.
- import { MoonCalc } from '@angelrov/forecast';
- SunCalc
SunCalc for calculating solar times, positions, and phases.
- import { SunCalc } from '@angelrov/forecast';
- astronomy/time-date
- astronomy/time-date
- astronomy/types
- Geolocation
- OpenMeteo:current
- OpenMeteo:daily
- OpenMeteo:hourly
- OpenMeteo:weatherSymbol
- utils
- utils
- utils
- utils
MoonCalc
MoonCalc for calculating moon times, positions, and phases.
- import { MoonCalc } from '@angelrov/forecast';
- MoonCalc
- ~phasesES :
Object.<string, string> - ~data(latitude, longitude, [date], [language]) ⇒
MoonData - ~dataExt(latitude, longitude, [date], [language]) ⇒
Object - ~emoji(latitude, longitude, [date]) ⇒
string - ~times(latitude, longitude, timezoneId, date) ⇒
Object - ~getUpOrDown(altitude, highest) ⇒
string
- ~phasesES :
MoonCalc~phasesES : Object.<string, string>
Mapa de fases lunares.
Kind: inner constant of MoonCalc
MoonCalc~data(latitude, longitude, [date], [language]) ⇒ MoonData
Kind: inner method of MoonCalc
| Param | Type | Default |
|---|---|---|
| latitude | number |
|
| longitude | number |
|
| [date] | Date |
new Date() |
| [language] | string |
"es-ES" |
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: inner method of MoonCalc
| Param | Type | Default |
|---|---|---|
| latitude | number |
|
| longitude | number |
|
| [date] | Date |
new Date() |
| [language] | string |
"es-ES" |
MoonCalc~emoji(latitude, longitude, [date]) ⇒ string
Kind: inner method of MoonCalc
Returns: string - - Emoji of the moon phase
| Param | Type | Default |
|---|---|---|
| latitude | number |
|
| longitude | number |
|
| [date] | Date |
new Date() |
MoonCalc~times(latitude, longitude, timezoneId, date) ⇒ Object
Kind: inner method of MoonCalc
| Param | Type |
|---|---|
| latitude | number |
| longitude | number |
| timezoneId | string |
| date | Date |
MoonCalc~getUpOrDown(altitude, highest) ⇒ string
Kind: inner method of MoonCalc
Returns: string - - Up or down emoji
| Param | Type |
|---|---|
| altitude | number |
| highest | Date |
SunCalc
SunCalc for calculating solar times, positions, and phases.
- import { SunCalc } from '@angelrov/forecast';
- SunCalc
- ~SunCalc
- ~all(date, latitude, longitude, timezoneId) ⇒
Object - ~times(date, latitude, longitude, timezoneId) ⇒
Object - ~getSolarTime(date, lng, offsetSign, offset) ⇒
string - ~position(latitude, longitude) ⇒
Object - ~getIsNight(lat, lon, timezoneId, date, dateStr) ⇒
boolean - ~getPhase(altitude, noon) ⇒
string
SunCalc~SunCalc
IMPORTANTE!!: ¡Solo proporcionar HORA LOCAL DEL SISTEMA!: 'new Date()' La única excepción es 'getSolarTime()': hay que darle la hora local correspondiente a la localización dada.
Kind: inner constant of SunCalc
SunCalc~all(date, latitude, longitude, timezoneId) ⇒ Object
Kind: inner method of SunCalc
| Param | Type |
|---|---|
| date | Date |
| latitude | number |
| longitude | number |
| timezoneId | string |
SunCalc~times(date, latitude, longitude, timezoneId) ⇒ Object
Kind: inner method of SunCalc
| Param | Type |
|---|---|
| date | Date |
| latitude | number |
| longitude | number |
| timezoneId | string |
SunCalc~getSolarTime(date, lng, offsetSign, offset) ⇒ string
Kind: inner method of 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 |
SunCalc~position(latitude, longitude) ⇒ Object
Kind: inner method of SunCalc
| Param | Type |
|---|---|
| latitude | number |
| longitude | number |
SunCalc~getIsNight(lat, lon, timezoneId, date, dateStr) ⇒ boolean
Kind: inner method of SunCalc
Returns: boolean - - true if it's night, false otherwise
| Param | Type |
|---|---|
| lat | number |
| lon | number |
| timezoneId | string |
| date | number | Date |
| dateStr | string |
SunCalc~getPhase(altitude, noon) ⇒ string
Kind: inner method of SunCalc
Returns: string - - The phase of the sun based on its altitude
| Param | Type |
|---|---|
| altitude | number |
| noon | string |
astronomy/time-date
- astronomy/time-date
- .timeString([date], [sec]) ⇒
string - .dateFormat([date]) ⇒
string - .getLocalTimeFromTz(timeZone, [date]) ⇒
string - .getLocalTimeInfo(apiKey, lat, lng) ⇒
Promise.<(any|LocalTimeData)>
- .timeString([date], [sec]) ⇒
astronomy/time-date.timeString([date], [sec]) ⇒ string
Formatea una fecha a un string legible.
Kind: static method of astronomy/time-date
Returns: string - La fecha formateada.
| Param | Type | Default |
|---|---|---|
| [date] | Date |
|
| [sec] | boolean |
false |
astronomy/time-date.dateFormat([date]) ⇒ string
Formatea una fecha a un string legible.
Kind: static method of astronomy/time-date
Returns: string - La fecha formateada.
| Param | Type | Default | Description |
|---|---|---|---|
| [date] | Date |
new Date() |
La fecha a formatear. |
astronomy/time-date.getLocalTimeFromTz(timeZone, [date]) ⇒ string
Get local time from timezone
Kind: static method of astronomy/time-date
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/time-date.getLocalTimeInfo(apiKey, lat, lng) ⇒ Promise.<(any|LocalTimeData)>
Google API: Get local time from any location
Kind: static method of astronomy/time-date
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/time-date
- astronomy/time-date
- .timeString([date], [sec]) ⇒
string - .dateFormat([date]) ⇒
string - .getLocalTimeFromTz(timeZone, [date]) ⇒
string - .getLocalTimeInfo(apiKey, lat, lng) ⇒
Promise.<(any|LocalTimeData)>
- .timeString([date], [sec]) ⇒
astronomy/time-date.timeString([date], [sec]) ⇒ string
Formatea una fecha a un string legible.
Kind: static method of astronomy/time-date
Returns: string - La fecha formateada.
| Param | Type | Default |
|---|---|---|
| [date] | Date |
|
| [sec] | boolean |
false |
astronomy/time-date.dateFormat([date]) ⇒ string
Formatea una fecha a un string legible.
Kind: static method of astronomy/time-date
Returns: string - La fecha formateada.
| Param | Type | Default | Description |
|---|---|---|---|
| [date] | Date |
new Date() |
La fecha a formatear. |
astronomy/time-date.getLocalTimeFromTz(timeZone, [date]) ⇒ string
Get local time from timezone
Kind: static method of astronomy/time-date
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/time-date.getLocalTimeInfo(apiKey, lat, lng) ⇒ Promise.<(any|LocalTimeData)>
Google API: Get local time from any location
Kind: static method of astronomy/time-date
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/types
- astronomy/types
- ~AstroPosition :
Object - ~MoonData :
Object - ~LocalTimeData :
Object
- ~AstroPosition :
astronomy/types~AstroPosition : Object
Kind: inner typedef of astronomy/types
Properties
| Name | Type |
|---|---|
| altitude | number |
| azimuth | number |
| direction | string |
| direction_full | string |
astronomy/types~MoonData : Object
Kind: inner typedef of astronomy/types
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/types~LocalTimeData : Object
Kind: inner typedef of astronomy/types
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. |
Geolocation
module.exports() ⇒ Promise.<{latitude: number, longitude: number, formatted_address: string}> ⏏
Get the current geolocation of the device and reverse geocode it to get the address.
Kind: Exported function
Throws:
ErrorIf geolocation is not supported or permission is denied.
OpenMeteo:current
OpenMeteo:current.useForecastCurrent(lat, lon, refreshIntervalMin) ⇒ Object
Custom hook to fetch current weather data from OpenMeteo API.
Kind: static method of OpenMeteo:current
| Param | Type |
|---|---|
| lat | number |
| lon | number |
| refreshIntervalMin | number |
OpenMeteo:daily
OpenMeteo:daily.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:daily
| Param | Type |
|---|---|
| lat | number |
| lon | number |
| refreshIntervalMin | number |
OpenMeteo:hourly
OpenMeteo:hourly.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:hourly
| Param | Type | Description |
|---|---|---|
| location | Object |
|
| dayNum | number |
Number of days from today: -1 = 24 hours, 0 = today, 1 = tomorrow, ... |
OpenMeteo:weatherSymbol
OpenMeteo:weatherSymbol.weatherSymbol(code, [precipitation], night, dark) ⇒ Object
Get weather symbol and description based on the weather code.
Kind: static method of OpenMeteo:weatherSymbol
| Param | Type |
|---|---|
| code | any |
| [precipitation] | number |
| night | boolean |
| dark | boolean |
utils
- utils
- static
- .degreesToCompass(degrees, language) ⇒
Object - .getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒
Object|null - .getWarning(precipitation, showers) ⇒
Object|null - .windArrowTx(deg)
- .getWindLevel(speed) ⇒
WindLevel|null
- .degreesToCompass(degrees, language) ⇒
- inner
- ~ALERT_LEVEL :
Array.<AlertLevel> - ~WIND_LEVELS :
Array.<WindLevel> - ~getWarningRain(precipitation) ⇒
Object|null - ~getWarningShowers(showers) ⇒
Object|null - ~AlertLevel :
Object - ~WindLevel :
Object
- ~ALERT_LEVEL :
- static
utils.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.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.getWarning(precipitation, showers) ⇒ Object | null
Get warning by precipitation and showers
Kind: static method of utils
| Param | Type |
|---|---|
| precipitation | number |
| showers | number |
utils.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.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~ALERT_LEVEL : Array.<AlertLevel>
Alert levels for rain and showers
Kind: inner constant of utils
utils~WIND_LEVELS : Array.<WindLevel>
Ordered list of wind levels.
Kind: inner constant of utils
utils~getWarningRain(precipitation) ⇒ Object | null
Get warning by rain
Kind: inner method of utils
| Param | Type |
|---|---|
| precipitation | number |
utils~getWarningShowers(showers) ⇒ Object | null
Get warning by showers
Kind: inner method of utils
| Param | Type |
|---|---|
| showers | number |
utils~AlertLevel : Object
Kind: inner 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: inner 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 |
utils
- utils
- static
- .degreesToCompass(degrees, language) ⇒
Object - .getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒
Object|null - .getWarning(precipitation, showers) ⇒
Object|null - .windArrowTx(deg)
- .getWindLevel(speed) ⇒
WindLevel|null
- .degreesToCompass(degrees, language) ⇒
- inner
- ~ALERT_LEVEL :
Array.<AlertLevel> - ~WIND_LEVELS :
Array.<WindLevel> - ~getWarningRain(precipitation) ⇒
Object|null - ~getWarningShowers(showers) ⇒
Object|null - ~AlertLevel :
Object - ~WindLevel :
Object
- ~ALERT_LEVEL :
- static
utils.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.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.getWarning(precipitation, showers) ⇒ Object | null
Get warning by precipitation and showers
Kind: static method of utils
| Param | Type |
|---|---|
| precipitation | number |
| showers | number |
utils.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.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~ALERT_LEVEL : Array.<AlertLevel>
Alert levels for rain and showers
Kind: inner constant of utils
utils~WIND_LEVELS : Array.<WindLevel>
Ordered list of wind levels.
Kind: inner constant of utils
utils~getWarningRain(precipitation) ⇒ Object | null
Get warning by rain
Kind: inner method of utils
| Param | Type |
|---|---|
| precipitation | number |
utils~getWarningShowers(showers) ⇒ Object | null
Get warning by showers
Kind: inner method of utils
| Param | Type |
|---|---|
| showers | number |
utils~AlertLevel : Object
Kind: inner 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: inner 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 |
utils
- utils
- static
- .degreesToCompass(degrees, language) ⇒
Object - .getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒
Object|null - .getWarning(precipitation, showers) ⇒
Object|null - .windArrowTx(deg)
- .getWindLevel(speed) ⇒
WindLevel|null
- .degreesToCompass(degrees, language) ⇒
- inner
- ~ALERT_LEVEL :
Array.<AlertLevel> - ~WIND_LEVELS :
Array.<WindLevel> - ~getWarningRain(precipitation) ⇒
Object|null - ~getWarningShowers(showers) ⇒
Object|null - ~AlertLevel :
Object - ~WindLevel :
Object
- ~ALERT_LEVEL :
- static
utils.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.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.getWarning(precipitation, showers) ⇒ Object | null
Get warning by precipitation and showers
Kind: static method of utils
| Param | Type |
|---|---|
| precipitation | number |
| showers | number |
utils.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.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~ALERT_LEVEL : Array.<AlertLevel>
Alert levels for rain and showers
Kind: inner constant of utils
utils~WIND_LEVELS : Array.<WindLevel>
Ordered list of wind levels.
Kind: inner constant of utils
utils~getWarningRain(precipitation) ⇒ Object | null
Get warning by rain
Kind: inner method of utils
| Param | Type |
|---|---|
| precipitation | number |
utils~getWarningShowers(showers) ⇒ Object | null
Get warning by showers
Kind: inner method of utils
| Param | Type |
|---|---|
| showers | number |
utils~AlertLevel : Object
Kind: inner 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: inner 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 |
utils
- utils
- static
- .degreesToCompass(degrees, language) ⇒
Object - .getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒
Object|null - .getWarning(precipitation, showers) ⇒
Object|null - .windArrowTx(deg)
- .getWindLevel(speed) ⇒
WindLevel|null
- .degreesToCompass(degrees, language) ⇒
- inner
- ~ALERT_LEVEL :
Array.<AlertLevel> - ~WIND_LEVELS :
Array.<WindLevel> - ~getWarningRain(precipitation) ⇒
Object|null - ~getWarningShowers(showers) ⇒
Object|null - ~AlertLevel :
Object - ~WindLevel :
Object
- ~ALERT_LEVEL :
- static
utils.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.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.getWarning(precipitation, showers) ⇒ Object | null
Get warning by precipitation and showers
Kind: static method of utils
| Param | Type |
|---|---|
| precipitation | number |
| showers | number |
utils.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.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~ALERT_LEVEL : Array.<AlertLevel>
Alert levels for rain and showers
Kind: inner constant of utils
utils~WIND_LEVELS : Array.<WindLevel>
Ordered list of wind levels.
Kind: inner constant of utils
utils~getWarningRain(precipitation) ⇒ Object | null
Get warning by rain
Kind: inner method of utils
| Param | Type |
|---|---|
| precipitation | number |
utils~getWarningShowers(showers) ⇒ Object | null
Get warning by showers
Kind: inner method of utils
| Param | Type |
|---|---|
| showers | number |
utils~AlertLevel : Object
Kind: inner 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: inner 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 |