private void Caclulate(DateTime date, int numdays, string id, int studyID, string act_timezone_property) { Days = new List <Daylight>(); targetdate = date; TimeZoneActigraph = LookupTimeZone(act_timezone_property); var zipCodes = ZipCodeSource.FromMemory().GetRepository(); SQL_utils sql = new SQL_utils("backend"); string code = String.Format("select left(zip,5) from trk.vwMasterStatus_S a where id='{0}' and studyID={1}" , id, studyID); string myDBzip = sql.StringScalar_from_SQLstring(code); sql.Close(); if (myDBzip.Contains("Error")) { Zip = "98195"; ZipDerivedFrom = "Default (address in DB is null)"; } else { Zip = myDBzip; ZipDerivedFrom = "address in DB"; } var myzipinfo = zipCodes.Get(Zip); Place = String.Format("{0}, {1}", myzipinfo.PlaceName, myzipinfo.StateAbbreviation); Lat = myzipinfo.Latitude; Lng = myzipinfo.Longitude; TimeZoneApiResultZip = LookupApiTimeZone(Lat, Lng); //TimeZoneZip = LookupTimeZone(myzipinfo.Latitude, myzipinfo.Longitude); for (int i = 0; i < numdays; i++) { DateTime tempdate = date.AddDays(i); SolarTimes solarTimes = new SolarTimes(tempdate, myzipinfo.Latitude, myzipinfo.Longitude); Daylight day = new Daylight() { Targetdate = tempdate, Sunrise = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunrise.ToUniversalTime(), TimeZoneActigraph), Sunset = TimeZoneInfo.ConvertTimeFromUtc(solarTimes.Sunset.ToUniversalTime(), TimeZoneActigraph) }; Days.Add(day); } }
public string GetText() { var text = new StringBuilder(); text.AppendLine("BEGIN:VTIMEZONE"); // header text.AppendLine($"TZID:{Id}"); if (!string.IsNullOrEmpty(Location)) { text.AppendLine($"X-LIC-LOCATION:{Location}"); } // definition text.Append(Daylight.GetText()); text.Append(Standard.GetText()); // end text.AppendLine("END:VTIMEZONE"); return(text.ToString()); }