Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8139865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:58:09+00:00 2026-06-06T11:58:09+00:00

My program takes in a date time packet from a hardware device, which is

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:58:11+00:00Added an answer on June 6, 2026 at 11:58 am
    int packetyear = year - year % 100 + packet[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which takes a long time to complete. I would like
My program takes user name and password authentication from user before initialising the program,
My C/C++ program takes a file from the command line as an argument. Reading
I have a program that takes characters from the buffer to form a string.
I am making a program that takes input from files that I have called
This is currently my MySQL UPDATE query, which is called from program written in
I have a program where I take a date from an RSS file and
I have the below program to obtain current date and time. int main(void) {
This program takes the first number in a file and indicates how many numbers
Basically the program takes customer information and dumps it in a database. In order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.