Reputation: 41
I convert from UTC to Julian Date. But I need to convert Julian Date to UTC. I researched but I didn't find any code in c#
I did UTC to Julian Date
I need Julian Date to UTC
Upvotes: 2
Views: 608
Reputation: 1587
You can use the NodaTime library FromJulianDayNumber
method to do the conversion to an instant from which you can get UTC, it will handle all of the minutia that the accepted answer does not handle.
Upvotes: 0
Reputation: 1444
Create this extension method:
public static class DoubleExtensions
{
public static DateTime JulianDateToUtc(this double julianDate)
{
var sinceEpoch = julianDate - 2440587.500000D;
return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddDays(sinceEpoch);
}
}
Then you can just do:
2458324.500000D.JulianDateToUtc();
Upvotes: 2