I’m trying to extract date from ticks.
Am I right that, a millisecond is 10000 ticks.
and a day is 864000000000 ticks and a month
is 26784000000000 and a year is 316224000000000.
but when I use these in computations, I get wrong date :(.
It could have been easy using Datetime parse but, for some reasons they say that I shouldn’t rely on it as it is rather slower.
Would appreciate your help. Thank you.
UPDATE:
//assume this for now
DateTime time = DateTime.Now;
char[] ashigakaricom= new char[] { 'yyyy','-','mm','-','dd','-','H','H',':','M','M',':','S','S',':','m','m','m' };
long ticks = time.Ticks;
int n1 = (int)(ticks >> 32);
int n2 = (int)ticks;
if (n2 < 0)
n1++;
ticks = (((Math.BigMul(429497, n2) - (int)(Math.BigMul(1161359156, n2) >> 32) - Math.BigMul(1161359156, n1)) >> 32)) + Math.BigMul(n1, 429497); n1 = (int)(ticks >> 32);
n2 = (int)ticks;
if (n2 < 0)
n1++;
int q = n1 * 50 + ((50 * (n2 >> 16)) >> 16) - (int)(System.Math.BigMul(1244382467, n1) >> 32) - 1;
int r = (int)(ticks - System.Math.BigMul(q, 86400000));
if (r > 86400000)
r -= 86400000;
//so on
I have several ideas on this: