@@ -9,7 +9,7 @@ const SunCalc = require("suncalc");
99 * @param {string } weatherType - OpenWeatherMap icon code (e.g., "01d", "02n")
1010 * @returns {string|null } Internal weather type
1111 */
12- function convertWeatherType ( weatherType ) {
12+ const convertWeatherType = ( weatherType ) => {
1313 const weatherTypes = {
1414 "01d" : "day-sunny" ,
1515 "02d" : "day-cloudy" ,
@@ -32,26 +32,26 @@ function convertWeatherType (weatherType) {
3232 } ;
3333
3434 return weatherTypes . hasOwnProperty ( weatherType ) ? weatherTypes [ weatherType ] : null ;
35- }
35+ } ;
3636
3737/**
3838 * Apply timezone offset to a date
3939 * @param {Date } date - The date to apply offset to
4040 * @param {number } offsetMinutes - Timezone offset in minutes
4141 * @returns {Date } Date with applied offset
4242 */
43- function applyTimezoneOffset ( date , offsetMinutes ) {
43+ const applyTimezoneOffset = ( date , offsetMinutes ) => {
4444 const utcTime = date . getTime ( ) + ( date . getTimezoneOffset ( ) * 60000 ) ;
4545 return new Date ( utcTime + ( offsetMinutes * 60000 ) ) ;
46- }
46+ } ;
4747
4848/**
4949 * Limit decimal places for coordinates (truncate, not round)
5050 * @param {number } value - The coordinate value
5151 * @param {number } decimals - Maximum number of decimal places
5252 * @returns {number } Value with limited decimal places
5353 */
54- function limitDecimals ( value , decimals ) {
54+ const limitDecimals = ( value , decimals ) => {
5555 const str = value . toString ( ) ;
5656 if ( str . includes ( "." ) ) {
5757 const parts = str . split ( "." ) ;
@@ -60,7 +60,7 @@ function limitDecimals (value, decimals) {
6060 }
6161 }
6262 return value ;
63- }
63+ } ;
6464
6565/**
6666 * Get sunrise and sunset times for a given date and location
@@ -69,13 +69,13 @@ function limitDecimals (value, decimals) {
6969 * @param {number } lon - Longitude
7070 * @returns {object } Object with sunrise and sunset Date objects
7171 */
72- function getSunTimes ( date , lat , lon ) {
72+ const getSunTimes = ( date , lat , lon ) => {
7373 const sunTimes = SunCalc . getTimes ( date , lat , lon ) ;
7474 return {
7575 sunrise : sunTimes . sunrise ,
7676 sunset : sunTimes . sunset
7777 } ;
78- }
78+ } ;
7979
8080/**
8181 * Check if a given time is during daylight hours
@@ -84,52 +84,52 @@ function getSunTimes (date, lat, lon) {
8484 * @param {Date } sunset - Sunset time
8585 * @returns {boolean } True if during daylight hours
8686 */
87- function isDayTime ( date , sunrise , sunset ) {
87+ const isDayTime = ( date , sunrise , sunset ) => {
8888 if ( ! sunrise || ! sunset ) {
8989 return true ; // Default to day if times unavailable
9090 }
9191 return date >= sunrise && date < sunset ;
92- }
92+ } ;
9393
9494/**
9595 * Format timezone offset as string (e.g., "+01:00", "-05:30")
9696 * @param {number } offsetMinutes - Timezone offset in minutes (use -new Date().getTimezoneOffset() for local)
9797 * @returns {string } Formatted offset string
9898 */
99- function formatTimezoneOffset ( offsetMinutes ) {
99+ const formatTimezoneOffset = ( offsetMinutes ) => {
100100 const hours = Math . floor ( Math . abs ( offsetMinutes ) / 60 ) ;
101101 const minutes = Math . abs ( offsetMinutes ) % 60 ;
102102 const sign = offsetMinutes >= 0 ? "+" : "-" ;
103103 return `${ sign } ${ String ( hours ) . padStart ( 2 , "0" ) } :${ String ( minutes ) . padStart ( 2 , "0" ) } ` ;
104- }
104+ } ;
105105
106106/**
107107 * Get date string in YYYY-MM-DD format (local time)
108108 * @param {Date } date - The date to format
109109 * @returns {string } Date string in YYYY-MM-DD format
110110 */
111- function getDateString ( date ) {
111+ const getDateString = ( date ) => {
112112 const year = date . getFullYear ( ) ;
113113 const month = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , "0" ) ;
114114 const day = String ( date . getDate ( ) ) . padStart ( 2 , "0" ) ;
115115 return `${ year } -${ month } -${ day } ` ;
116- }
116+ } ;
117117
118118/**
119119 * Convert wind speed from km/h to m/s
120120 * @param {number } kmh - Wind speed in km/h
121121 * @returns {number } Wind speed in m/s
122122 */
123- function convertKmhToMs ( kmh ) {
123+ const convertKmhToMs = ( kmh ) => {
124124 return kmh / 3.6 ;
125- }
125+ } ;
126126
127127/**
128128 * Convert cardinal wind direction string to degrees
129129 * @param {string } direction - Cardinal direction (e.g., "N", "NNE", "SW")
130130 * @returns {number|null } Direction in degrees (0-360) or null if unknown
131131 */
132- function cardinalToDegrees ( direction ) {
132+ const cardinalToDegrees = ( direction ) => {
133133 const directions = {
134134 N : 0 ,
135135 NNE : 22.5 ,
@@ -149,23 +149,23 @@ function cardinalToDegrees (direction) {
149149 NNW : 337.5
150150 } ;
151151 return directions [ direction ] ?? null ;
152- }
152+ } ;
153153
154154/**
155155 * Validate and limit coordinate precision
156156 * @param {object } config - Configuration object with lat/lon properties
157157 * @param {number } maxDecimals - Maximum decimal places to preserve
158158 * @throws {Error } If coordinates are missing or invalid
159159 */
160- function validateCoordinates ( config , maxDecimals = 4 ) {
160+ const validateCoordinates = ( config , maxDecimals = 4 ) => {
161161 if ( config . lat == null || config . lon == null
162162 || ! Number . isFinite ( config . lat ) || ! Number . isFinite ( config . lon ) ) {
163163 throw new Error ( "Latitude and longitude are required" ) ;
164164 }
165165
166166 config . lat = limitDecimals ( config . lat , maxDecimals ) ;
167167 config . lon = limitDecimals ( config . lon , maxDecimals ) ;
168- }
168+ } ;
169169
170170module . exports = {
171171 convertWeatherType,
0 commit comments