Package Exports
- @angelrove/forecast-utils
Readme
Modules
- 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
- Utils/TimeDateStr
Helpers for get date and time formeted strings
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> - .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 - .MoonData :
Object
- .phasesES :
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 - .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
- .all(date, latitude, longitude, timezoneId) ⇒
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}> - .exports.timeFromLocation(apiKey, lat, lng) ⇒
Promise.<(any|LocalTimeData)>
- .exports.getGeolocation() ⇒
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:
ErrorIf geolocation is not supported or permission is denied.
Geolocation.exports.timeFromLocation(apiKey, lat, lng) ⇒ Promise.<(any|LocalTimeData)>
Get local time from a given location (lat, lng) using 'GoogleMaps TimeZone' API.
Kind: static method of Geolocation
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 |
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> - .directionsEs :
Array.<Compass> - .ALERT_LEVEL :
Array.<AlertLevel> - .WIND_LEVELS :
Array.<WindLevel> - .exports.degreesToCompass(degrees, language) ⇒
Object - .exports.getWarningByDays(precipitationSumToday, precipitationSumTomorrow, showersSumToday, showersSumTomorrow) ⇒
Object|null - .exports.getWarning(precipitation, showers) ⇒
Object|null - .exports.WindArrow(props)
- .exports.windArrowTx(deg)
- .exports.getWindLevel(speed) ⇒
WindLevel|null - .Compass :
Object - .AlertLevel :
Object - .WindLevel :
Object
- .directions :
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.WindArrow(props)
SVG arrow indicating wind direction.
Kind: static method of Utils
Component: JSX
| Param | Type | Description |
|---|---|---|
| props | Object |
Component props. |
| props.deg | number |
Wind direction in degrees (0 = North, 90 = East, etc.). |
| [props.size] | string |
Tailwind CSS size class (e.g., 'size-10') |
| [props.strokeWidth] | number |
Stroke width of the arrow (range: 1–6). |
| [props.className] | string |
Additional CSS classes. |
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 |
Utils/TimeDateStr
Helpers for get date and time formeted strings
- Utils/TimeDateStr
- .dateFormat([date]) ⇒
string - .timeString([date], [sec]) ⇒
string - .nowString(sec) ⇒
String - .getLocalTimeFromTz(timeZone, [date]) ⇒
string
- .dateFormat([date]) ⇒
Utils/TimeDateStr.dateFormat([date]) ⇒ string
Returns a date as a formated string.
Kind: static method of Utils/TimeDateStr
Returns: string - La fecha formateada.
| Param | Type | Default | Description |
|---|---|---|---|
| [date] | Date |
new Date() |
La fecha a formatear. |
Utils/TimeDateStr.timeString([date], [sec]) ⇒ string
Returns a time as a formated string.
Kind: static method of Utils/TimeDateStr
Returns: string - La fecha formateada.
| Param | Type | Default |
|---|---|---|
| [date] | Date |
|
| [sec] | boolean |
false |
Utils/TimeDateStr.nowString(sec) ⇒ String
Returns a now time as a formated string.
Kind: static method of Utils/TimeDateStr
| Param | Type | Default |
|---|---|---|
| sec | boolean |
false |
Utils/TimeDateStr.getLocalTimeFromTz(timeZone, [date]) ⇒ string
Return the local time string from a given timezone.
Kind: static method of Utils/TimeDateStr
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. |