title: Google Sheets Custom Function API: Return Sunrise/sunset + GMT/DST Offset based on lat/long
body: <p>I'd like to have the function return the sunrise or sunset formatted with the appropriate GMT offset based on the coordinates. I found a different API that lets you get sunrise/set times for a given date and location as well as providing GMT or DST offset.</p>
  
  <pre><code>function SunRiseSet(lat,long,date,type) {
   var response  
   UrlFetchApp.fetch("http://api.geonames.org/timezoneJSON?"+lat+"&amp;lng="+long+"&amp;username=northfacejmb"+lat+"&amp;lng="+long+"&amp;date="+date);
  
   var json = response.getContentText();
   var data = JSON.parse(json);
   var sunrise = data.dates.sunrise;
   var sunset = data.dates.sunset;
   var gmtOffset = data.gmtOffset;
   var dstOffset = data.dstOffset;
  
   if (type == 1) {
      return sunrise-gmtOffset;
                   } else {
        return sunset-gmtOffset;
             };
  }
  </code></pre>
  
  <p>Any help is appreciated! - Jeremy</p>
  
  <p>For context: <a href="https://stackoverflow.com/questions/48040528/import-sunrise-set-based-on-coordinates-into-google-sheet-using-api">Import Sunrise/Set based on coordinates into Google Sheet using API</a></p>