// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { private const double TICKS_PER_DAY = 24*60*60*10000000L; //private static readonly double OFFSET = 2400000 - (new DateTime(1858, 11, 16, 12, 0, 0)).Ticks/TICKS_PER_DAY; private static readonly double OFFSET = 2400000 - (new DateTime(1858, 11, 16, 12, 0, 0)).ToUniversalTime().Ticks/TICKS_PER_DAY; public static double DT2JD(DateTime dt) { return dt.Ticks/TICKS_PER_DAY + OFFSET; } public static void Main(string[] args) { Console.WriteLine(DT2JD(DateTime.Now)); Console.WriteLine(DT2JD(DateTime.Parse("02-Feb-1989"))); Console.WriteLine(DT2JD(new DateTime(1858, 11, 16, 12, 0, 0))); } } }