Tronald/CoordinateSharp

Coordinate.Offset has improper range limitation.

bp2008 opened this issue · 3 comments

Describe the bug

Coordinate.Offset refuses to accept a value greater than 12. Exception is thrown: "Time offsets cannot be greater than 12 or less than -12."

Locations such as Kiribati have time zone offsets as high as 14. Wikipedia UTC time offsets list.

To Reproduce
Please provide a reproducible code example if able.

Coordinate c = new Coordinate(1.466667, 173.033333, DateTime.Now);
c.Offset = 14;

Expected behavior
Coordinate Offset accepted range should be -12 to 14.

Environment (please complete the following information):

  • .NET version. .NET Framework 4.5.2
  • CoordinateSharp version. 2.11.1.1
  • Application type. Windows Application
  • Is mutlithreading being used? Yes

Additional context
Add any other context about the problem here.

Offset needs +2 hour validation extension.

Great catch thank you. The initial design was around a 24 clock from UTC midpoint, without consideration to location and IDL adjustments in those areas. Obviously this can cause issues for local time applications.

We will get this patched up quickly.

Patch is built for CoordinateSharp, I just need to button up a few things before I push it (should be on Nuget in the next hour). I want to note a few odd things I noticed about this region though. Most webservices seem to exhibit the same behavior (with +12 UTC offset max).

For example Time and Date says LINT is +14 : https://www.timeanddate.com/time/zones/lint
But their sun times appear in +12: https://www.timeanddate.com/sun/@4030885

NOAA however seems to exhibit the correct behavior when setting +14 UTC (notice the 2 hour difference in reported time): https://gml.noaa.gov/grad/solcalc/

image

I bring this up, because testing in this region may require additional research. The math in CoordinateSharp is correct though from testing (adding 14 hours from UTC for solar/lunar calculation).

CoordinateSharp Reported Time in Regions

SUNSET: 9/28/2021 8:21:52 PM
SUNRISE: 9/28/2021 8:15:35 AM

Patch pushed to Nuget with v2.12.1.1