last day (15 days later) » 

12:02 PM
2
A: 32bit Hex to date time

LPsUsing the perfect explanation of @dbush, below you can find a simple linux gcc compiled code. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <time.h> void decrypt ( uint32_t data ) { uint16_t mydate = data>>16; uint16_t mytime = data&0x0000FFFF;...

 
dbush says that the dates to be added from 1993-12-17 but LPs compiled example code add the date from 1/1/1970 is two methods give the same result or different
 
LPs
@rmrps I added days from 1/1/1970 to 17/12/1993 because of linux base time used by time.h. Output is exact what you wrote in your post, but localized. In my case GMT+1 (Italy)
 
Now i am understand the days thanks for the effort @LPs , dbush one more doubt what will be the output for your example using uint16_t mydate = 0x5501; uint16_t mytime = 0xDC8B;printf(ctime(&linuxSeconds)); that is final output of printf(ctime(&linuxSeconds)); how it will be shows
 
LPs
@rmrps I edited. Output added.
 
thanks for the effort @LPs if the sample data 57 01 DC 8B will be wrong what is the changes in program same or different one. and if unix time calculates leap year also then why the last sample give error result
 
LPs
12:02 PM
@rmrps I'm not getting you. The output is the one shown in your post. Is 1 hours more because of the GMT difference. Do you means: how to take care of GMT?
 
yes i want to know about the GMT and want to know about DST also
 
LPs
@rmrps I edited. The example now show you how to retrieve and correct the timezone of the machine where the program is executed.
 
The GMT is same for all the data then how it will differ in last sample .
Thanks @dbush the all above functions are inbuilt function of c program or not (with time.h header file)
Thanks for the effort @dbush
 
LPs
I edited using functions suggested by @dbush
 
Thanks for all support. I have recently added one more sample data 42 23 8F 96 =(02-Jun-09 17:06:30) . so from all sample datas my conclusion is the time part is over there is no confusion in that i have doubt only in date part that is the last two samples 57 01 DC 8B which give (1day differ insted of 14-apr-14 it gives 15-apr-14 ) and 42 23 8F 96 (3 days differ) that is the original date from sample is 02-jun-09 but as per the program i am getting 30-may-09.
 
LPs
12:02 PM
@rmrps could you post two dates near 2K? I means, eg: 31/12/1999 and 15/03/2000. The date after 2K must be after february.
 
i will update soon
Lot of difference there the sample data is 3C F5 28 4B= (31-mar-2000 18:51:55) and 3A F4 28 49 =(12-Oct-1999 18:51:53) corresponding output from as per program 3C F5 28 4B= (14-mar-2008 18:51:55) and 3A F4 28 49 =(25-Sep-2007 18:51:53)
 
LPs
@rmrps It is very strange that 42 23 and 3C F5 has a difference of 1326 units and dates differs of 3360 days...
 
yes i am also having the same doubt the time part is over but date part is something different than expected
 
LPs
I updated the script. New dates are correct. 0x42238F96 stil not correct. Could you please post other dates near that one?
 
yes @Lps
I found one answer i think the start of the date is 1-Jan-1986
 
12:07 PM
Also note that in the two new samples the MSB of byte 3 is NOT set.
 
And if i am setting the msb bit that is 00 03 80 00 the answer will be 1-Jan-94
As per our datas 00 00 00 00 is 1-Jan-1986
and if data like 00 03 00 00 also 1-jan-1986
if 00 04 00 00 means 1-jan-1986 08:00:00
10 06 70 04=29 sep-89 15:57:56
@ Lps your new script not working the output screen black i am testing using turbo c
 
12:23 PM
Based on 26-Oct-13, 14-Apr-14 is one more than it should be and 02-Jun-09 is 3 less than it should be....
the years of 26-Oct-13 and 14-Apr-14 differ by one, while the years of 26-Oct-13 and 02-Jun-09 differ by 4. However in the latter case, there is a leap year in between.
So perhaps this encoding is assuming 29 days for Feb
 
between 2009 to 2013 1 leap year is there
if 29 days for feb means 2-jun-2009 differ 3 days how it comes
 
LPs
I really don't know. Seem to me that if MSB of byte 3 is set the start date is 17/12/1993 and if it is not set the start date is 19/03/1984...
 
Actually, I think the start date is 1994-1-1
 
LPs
The new posted code take care of this bit in that way
 
If the encoding is improperly counting leap days, 2013 would be 15 days off. 1993-12-17 + 15 days is 1994-1-1
 
12:30 PM
30 06 70 04 gives the result=24-mar-1997 07:56:56
@dbush what about start date from 1-Jan-1986
please tell me any hex data if you wish to check
i will provide the date value for the corresponding hex data from that you can find the algorithm
 
LPs
My output for 30 06 70 04 is Mon Mar 24 07:57:56 1997
@dbush I'm not getting you: 15 leap ears form what?
 
2C067004 and 29567004
@LPs From 1994 to 2013 inclusive there are 15 non-leap years
If the encoding is assuming all years have Feb 29, that explains the discrepancies.
 
LPs
ok, NOT leap years. I was counting leap years.
 
for 2C067004 =15 apr-96 23:57:56
 
LPs
My output for 2C067004=Tue Apr 16 23:57:56 1996 and for 29567004=Thu Aug 31 15:57:56 1995
 
12:39 PM
for 29567004=30 aug-95 15:57:56
 
Both 1 day ahead, but 1996 is a leap year.
 
i think they are not counting leap years
please give me any other hex code
 
LPs
Could be but why first 2 cases are correct?
 
correct . give me some other hex code we will veryfied
 
13567004, 17567004, 1C567004, 20567004, 24867004,
LPs's code gives Wed Jul 11 07:57:56 1990, Mon Jun 17 15:57:56 1991, Mon Aug 17 07:57:56 1992, Sat Jul 24 15:57:56 1993, Sat Jul 16 23:57:56 1994
 
12:45 PM
13567004=9-jul-90 7:57:56
17567004=15-jun-91 15:57:56
 
Two days behind, two non-leap days between then and 1994-1-1
 
LPs
2 days less and 2 leap years from 19/03/1984
 
Also two behind, I'd expect one behind
 
1C567004=15-aug-92 07:57:56
 
LPs
Ok The algorithm not count leap years: is a fact.
 
12:49 PM
20567004=23-jul-93 15:57:56
24867004=15-jul-94 23:57:56
if data like this 24868004=7-jul-02 16:00:04
that is 3rd byte msb is set means 8 years added
 
Let's back up....
12-Oct-99 is 5032 days before 1986-1-1
 
please try @dbush any other hex code you want to be checked
 
But the encoding we have for that says 5030 days.
That's a difference of two days, and there are two leap years in between.
 
any if condition we will provide for that
 
So if byte 3 MSB is cleared, then epoch is 1986-1-1 and all years have 365 days.
And if byte 3 MSB is set, then epoch is 1994-1-1 and all years have 366 days.
 
12:59 PM
yes correct
it is possible to check our assumption is correct please give some other hex code
 
LPs
@dbush the real problem is that first 2 examples are correct with my code: why?
 
@LPs 1970-1-1 and 1986-1-1 differ by 5844 days. Your code currently uses 5846
 
@Lps forgot about the examples lets we tried with some other hex code from that we will find why that is correct
 
LPs
but for the third 14/04/2014 is not
 
no it differ by 5843 days
as per our records 00 03 00 00 means 01-jan-1986
and also if 00 00 00 00 means 1-jan-1986
if it increase 00 04 00 00 =1-jan-1986 08:00:00
 
LPs
1:07 PM
Sorry, one simple question. Where data came from? A text file or is the output of a program? I mean are you finding this data (hex and related date and time) from a log file or is a program that gives you date and time whe you input the hex code?
 
That is came from log file generated by software if we give hex code to that software it will produce corresponding date and time value
any answer your getting
 
1:43 PM
@LPs,@dbush the Sigve Kolbeinson program will give correct result
 
1:54 PM
No it is not giving correct result
@LPs have you get the answer
@dbush have you get the answer
 
What is 2B067004?
 
I'm sorry I'm pretty inactive now, my family have arrived home, and it's my son's birthday, so I won't be able to be very active until they're in bed
but I see that my code is out by 1 day on the latest two timestamps
 
2B067004=21-jan-96 15:57:56
@dbush any idea have you got
Thanks @sigve kolbeinson
 
2:12 PM
can I ask more about the software that logs this - what is it logging - is there anything that could explain why there are different schemes?
afk
 
That logs contain only date time data if you give hex code as input it will give corresponding date time value according to their algorithm
 
So it looks like the 1986 scheme does do a leap year check but only for the current year.
 
2:29 PM
ok if current year is leap year means what we have to do
let us tried using some other hex code?
5B067004=12-Apr-07 15:57:56
5B068004=22-Mar-15 08:00:04
 
2:47 PM
Those come up good.
 
@dbush have you got any idea
 
I'm in the process of updating my answer
 
thanks for your effort @dbush
 
LPs
3:15 PM
I'm going abroad at the moment, and I cannot code, but seems that for each grup of 8 year the leap are reset. I mean from 1986 to 1994, from 1994 and 2002, 2002 and 2010.
 
Thanks for trying @LPs
Waiting for your answer @dbush
 
4:20 PM
have you finished editing the answer @dbush
 
4:37 PM
@rmrps Yes, the answer is updated.
 
thanks dbush i will check it and tell you dbush
One more thing dbush if i want to work with turbo c what is the changes i have to made
 
I don't have access to Turbo C, so you'll need to compile it yourself and fix any errors it reports.
 
4:53 PM
In turbo c i am getting only 1-jan-94 00:00:04 i think problem in struct declaration
 

  last day (15 days later) »