I have a date represantation with the following order in order to fit an int. The date represantation should be
year : 6 bits
month : 5 bits
day : 5 bits
hours : 4 bits
minutes: 6 bits
seconds: 6 bits
All the dates should be fit into an Unit32 date
[year(5bits),month(5bits),day(6bits),hours(4bits),minutes(6bits),seconds(6bit)]
UInt32 date = 0;
date= date| (UInt32) (DateTime.Now.Year%2000)<< 26;
date= date| ((uint)DateTime.Now.Month << 22);
date= date| (uint)DateTime.Now.Day << 17;
date= date| ((uint)DateTime.Now.Hour << 15);
date= date| ((uint)DateTime.Now.Minute << 6);
date= date| ((uint)DateTime.Now.Second);
string binary = Convert.ToString(date, 2);
Above i have tried some bitwise operation but the result doestn satisfy. what i am missing or what should i do?
For Example current date is: 2021.55.10 13:55:06 Binary conversion above code 1010100110101101000110111000011 hex mean 54D6 8DC3 that means Thursday, 1 January 1970 06:01:58 but it should be today's date
thanks.