Date encoding as integer please help

J

Jcs_5920

Hello All, I was reading some of the posts trying to learn about date
coding schemes used in old DOS programs with no luck, so I though I'd
ask the group for help.
These are the HEX values and corresponding dates I am using. If anyone
can help me figure out the encode / decode method I would really
appreciate it.
Date only, no time stored.
9C07 0B00 = 01-15-80
9D07 0B00 = 01-16-80
BB07 0B00 = 02-15-80
BC07 0B00 = 02-16-80
3D2C 0B00 = 09-17-05
3E2C 0B00 = 09-18-05

Please help, I'm new to programming & trying to learn on my own.
JCS
 
J

Jack Klein

Hello All, I was reading some of the posts trying to learn about date
coding schemes used in old DOS programs with no luck, so I though I'd
ask the group for help.
These are the HEX values and corresponding dates I am using. If anyone
can help me figure out the encode / decode method I would really
appreciate it.
Date only, no time stored.
9C07 0B00 = 01-15-80
9D07 0B00 = 01-16-80
BB07 0B00 = 02-15-80
BC07 0B00 = 02-16-80
3D2C 0B00 = 09-17-05
3E2C 0B00 = 09-18-05

Please help, I'm new to programming & trying to learn on my own.
JCS

The C++ language defines a type named 'time_t' that represents times,
and does not define its representation, which varies from system to
system. If you are using a C++ compiler, you should be able to call
time() prototyped in the header <time.h> or <ctime> that will return a
time_t, and there are various functions that will convert it to text
for you.

On the other hand, if you are talking about something like the time
stamp format MS-DOS used on disk files, you need to ask in a platform
specific group. is the right place.
 
P

Phil Staite

Jcs_5920 said:
Hello All, I was reading some of the posts trying to learn about date
coding schemes used in old DOS programs with no luck, so I though I'd
ask the group for help.
These are the HEX values and corresponding dates I am using. If anyone
can help me figure out the encode / decode method I would really
appreciate it.
Date only, no time stored.
9C07 0B00 = 01-15-80
9D07 0B00 = 01-16-80
BB07 0B00 = 02-15-80
BC07 0B00 = 02-16-80
3D2C 0B00 = 09-17-05
3E2C 0B00 = 09-18-05

Please help, I'm new to programming & trying to learn on my own.
JCS

The first-best clue is that only one digit is off between two
consecutive dates - the "9C..." to "9D..." from 1/15/80 to 1/15/80.
That tells me that it is probably a simple 32 bit "little endian" number.

If you buy that, then in more common "source code" format your numbers
look like:

0x000B079C for 1/15/80
0x000B079D for 1/16/80
0x000B07BB for 2/15/80
0x000B07BC for 2/16/80
0x000B2C3D for 9/17/05
0x000B2C3E for 9/18/05

I put 1/15/80 into an OpenOffice spreadsheet, then converted 0x0B079C to
decimal (722844). Subtracting ('cause I know spreadsheets keep dates as
numbers of days) gives me an "epoch" date of 12/18/0001. Go figure. A
sanity check shows that 0x0B2C3E is 732222 and that by adding that to
the epoch date we get 9/18/05...
 
R

Robbie Hatley

Jcs_5920 said:
Hello All, I was reading some of the posts trying to learn about date
coding schemes used in old DOS programs with no luck, so I though I'd
ask the group for help.
These are the HEX values and corresponding dates I am using. If anyone
can help me figure out the encode / decode method I would really
appreciate it.
Date only, no time stored.
9C07 0B00 = 01-15-80
9D07 0B00 = 01-16-80
BB07 0B00 = 02-15-80
BC07 0B00 = 02-16-80
3D2C 0B00 = 09-17-05
3E2C 0B00 = 09-18-05

Please help, I'm new to programming & trying to learn on my own.

A bit off-topic (should really go to a general programming
group such as "comp.programming", or maybe a DOS group such
as "comp.os.msdos.misc")...

.... but I see the answer, so I'll reply briefly.

The hex numbers on the left are days, in little-endian format.
Do the math: 000B2C3E(Hex) = 732222(Dec).
Divide by 365.25 and get 2004.7146 years, which is around
September 18 of a year which is 2004 years past some "base"
year. Hence that base year must have been the year 1AD.
(Which makes sense, because there was no year "0".)

So your encoding scheme is, "days since 1-1-1AD, in hex,
little-endian".

Which means DOS, under the surface, was sort-of Y2K compliant,
even though it only displayed 2-digit years. Interesting.

--
Cheers,
Robbie Hatley
Tustin, CA, USA
email: lonewolfintj at pacbell dot net
web: home dot pacbell dot net slant earnur slant
 
J

Jcs_5920

Thank you all soooo MUCH, I am still learning but this gives me
something to sink my teeth in.

p.s. sorry for being in the wrong group, like I said I am very new to
this.
Best wishes to all.

JCS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top