My program takes in a date time packet from a hardware device, which is of type byte. An example packet is:
byte[] packet = new byte[] {0x0C, 0x01, 0x15};
//packet[0] is the last two numbers of the year
As stated in the comments, packet[0] represents the last two numbers of the year. So, for example, this would translate to 2012 in decimal.
Now my question is, how do I return 2012 to the user? For the first two numbers of the year, “20”, I know I can call:
int systemYear = DateTime.Now.Year;
Which returns: 0x000007dc, or 20’12’ in decimal. I need no somehow remove the last two numbers from the year, in this case “12” and insert the packet[0] byte in that location instead.
I don’t always want to assume we are in the year “20XX”. If this program is run in the year 2101, this would cause problems.
Also, I can’t always assume that the hardware will return the current year we are living in. This is what my program is actually going to check.
So, say for example packet[0] = 0x02. This would assume the hardware returned the year 2002.
What is the best way to achieve this?
1 Answer