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

  • Home
  • SEARCH
  • 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 3459932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:10:05+00:00 2026-05-18T10:10:05+00:00

There is a time represented in MJD and BCD format with 5 bytes .I

  • 0

There is a time represented in MJD and BCD format with 5 bytes .I am wondering what is the recommended format to save this date-time in the sqlite database so that user can search against it ?

My first attempt is to save it just as it is, that is a 5 bytes string. The user will use the same format to search and the result will be converted to unix time by the user with following code.

However, later, I was suggested to save the time in the integer – the UTC time, for example. But I can not find a standard way to do the conversion.

I feel this is a common issue and would like to hear your comments.

time_t sidate_to_unixtime(unsigned char sidate[])
{
int k = 0;
struct tm tm;
double mjd;

/* check for the undefined value */
if ((sidate[0] == 0xff) &&
    (sidate[1] == 0xff) &&
    (sidate[2] == 0xff) &&
    (sidate[3] == 0xff) &&
    (sidate[4] == 0xff)) {
    return -1;
}

memset(&tm, 0, sizeof(tm));
mjd = (sidate[0] << 8) | sidate[1];

tm.tm_year = (int) ((mjd - 15078.2) / 365.25);
tm.tm_mon = (int) (((mjd - 14956.1) - (int) (tm.tm_year * 365.25)) / 30.6001);
tm.tm_mday = (int) mjd - 14956 - (int) (tm.tm_year * 365.25) - (int) (tm.tm_mon * 30.6001);
if ((tm.tm_mon == 14) || (tm.tm_mon == 15)) k = 1;
tm.tm_year += k;
tm.tm_mon = tm.tm_mon - 2 - k * 12;

    tm.tm_sec = bcd_to_integer(sidate[4]);
tm.tm_min = bcd_to_integer(sidate[3]);
tm.tm_hour = bcd_to_integer(sidate[2]);

return mktime(&tm);
 }
  • 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-05-18T10:10:05+00:00Added an answer on May 18, 2026 at 10:10 am

    Save it as UTC . THis is your best bet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to format a UTC time into any arbitrary string format
Is there an algorithm that is more time efficient than O(n^2) for detecting cycles
I'm writing a Java Swing application using the Metal look-and-feel. Every time there is
Is there a polynomial time algorithm for finding a Hamiltonian walk in a graph?
There are a number of run-time differences in compatible code between these two versions
Is there a good way to time SQL queries when using Linq to SQL?
Are there any other IDEs worth my time for Lotus Notes development? We're doing
Is there any way to get the time down to the Millisecond in MySQL?
Is there a way to identify at run-time of an executable is being run
Is there any way to enable execution-time variable expansion for cmd.exe (normally done by

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.