Skip to content

Instantly share code, notes, and snippets.

@bjartwolf
Created May 3, 2015 21:37
Show Gist options
  • Save bjartwolf/0d1884bde4f6d9eeef23 to your computer and use it in GitHub Desktop.
Save bjartwolf/0d1884bde4f6d9eeef23 to your computer and use it in GitHub Desktop.
let findHoursInNorwegianDay (year:int) (month:int) (day: int) :int =
let zone = DateTimeZoneProviders.Tzdb.GetZoneOrNull("Europe/Oslo")
let t1 = new LocalDateTime(year, month,day,0,0)
let t2 = t1.PlusDays(1)
let z1 = t1.InZoneLeniently(zone)
let z2 = t2.InZoneLeniently(zone)
let interval = z2.ToInstant()- z1.ToInstant()
int (System.Math.Round(TimeSpan.FromTicks(interval.Ticks).TotalHours,0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment