the Un*x epoch time, (32bit, seconds since 1/1/1970) will roll over sometime in july 2038, still the same problem in 39 years (that's not very far away)!!! I think somebody should try and invent a signed 64bit coding and implement it as a standard method of storing dates!!!! (i.e. seconds since 1/1/1 or something) 64 bits=63 bits +ve or -ve => 292271023045 years with the resolution of one second! 292271 years in 1uS resolution. At 19:36 10/01/99 , you wrote: >> How to keep date > > Well, unless the device has to display time somehow in ASCII or digits, >I strongly prefer the Unix date format (unsigned 32 bits, seconds since >etc etc). When there is a timezone problem (there is, here), I add a >signed integer in 32 bits that expresses the offset to GMT and a ISO >3-char string that expresses the ISO name of the offset to GMT/UTC. I >confess that I have only gotten to do this twice so far, but it is a Good >Thing imho. > > It only takes 11 bytes to implement and doing date maths with this is >bliss compared to YYMMDD - YYMMDD etc. The date can be transmitted in >mangled format over serial, using hex ASCII if there is an >8-bit-uncleanliness problem (we are 8-bit clean because our national >character set maps up into >0x80 bytes normally). Hosts have no problem >formatting or parsing the date, especially since the time functions are >well represented in any C standard library. > > Note that I use an UNSIGNED second counter, which is good till 2106 or >so. The C library functions usually aren't. I also use only the low bits >of the offset required to express a +/-12 Hour offset in seconds. This is >17 bits + sign = 18 bits out of 32. This leaves some unused bits and bytes >(can be flags etc). The 32-bit alignment is kept for easy addition >purposes. A mask removes the flags when doing this. > >One can implement the binary->ASCII parser even on a PIC if need be, but >for simple things like clocks YYMMDDSS is more like it, in packed or >unpacked BCD, ready to add ASCII offsets for display (LCD) or not (LEDs >etc). > >hope this helps, > >Peter > _____________________________________________________ Osama ALASSIRY osama@qatar.net.qa osama@alassiry.com http://www.alassiry.com