Are there any built in api's within dotnet that will tell you how many hours there are within a specified day?
This assumes that the API will appreciate daylight savings for a given timezone. So for the UK moving from GMT into summertime, there would be 23 hours in the day, and 25 in the summertime back to GMT.
I haven't as yet spotted anything in nodatime to do this directly.
I can do something like the following in NodaTime but are there any better ways?
DateTimeZone london = DateTimeZoneProviders.Tzdb["Europe/London"];
LocalDate start = new LocalDate(2021, 3, 28);
LocalDate end = new LocalDate(2021, 3, 29);
ZonedDateTime startZ = london.AtStartOfDay(start);
ZonedDateTime endZ = london.AtStartOfDay(end);
ZonedDateTime dt = startZ;
int period = 1;
while (dt.ToInstant() < endZ.ToInstant())
{
testOutputHelper.WriteLine("Period: " + period + ", " + dt.ToString() + ", Hour: " + dt.Hour);
dt = dt.PlusHours(1);
period++;
}