79106702

Date: 2024-10-20 09:18:13
Score: 0.5
Natty:
Report link

Thanks Mark - I had to make a minor change as it looks like the .Net tick counter is different to Python. My code looks like:

        public DateTime ExtractTime(string GUID)
        {
            var Parts = GUID.Split('-');           

            // 100-ns intervals since 10/15/1582 00:00:00.  60 bits.
            // Trim off 1st digit of parts[2] as it is the UUID version.
            //           12 bits    +  16 bits + 32 bits
            var HexTime = Parts[2].Substring(1) + Parts[1] + Parts[0];
            var Time = Convert.ToInt64(HexTime, 16);

            var Epoch = new DateTime(1582, 10, 15);
            var Diff = TimeSpan.FromTicks(Time);
            
            return Epoch.Add(Diff);
        }
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Nigel Tunnicliffe