Time of Day functions on micro

Hi All,

I need to convert seconds since 1900 into calender format and back again, just like mktime etc. I wish to do this on a microcontroller with no time libraries.

Does anyone have the source code for this function?

Regards Wayne

Reply to
Wayne Peacock
Loading thread data ...

30 seconds on Google came up with this link....
formatting link

Peter

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/04
Reply to
moocowmoo

What type of micro. Note that if you start the epoch in 1900, the numbers you'll have to handle are pretty huge (using a 32 bit unsigned int, it'll still run over in 2036). That might well stretch, e.g., an

8-bit micro beyond reasonable limits. Year 2000 makes for a considerably easier choice of epoch. To put it another way: does your embedded system really have to deal with calender dates from the *past*?

GNU libc, or any other sufficiently free implementation of libc, should do. Most of those will be assuming seconds since 1970, but that shouldn't pose an extra problem.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

...which is clearly marked as GNU GPL code. You can't simply lift those sources for your own benefit.

Rob

Reply to
Rob Turk

Sure you can. You just can't lift them for your *sole* benefit, and you must make the source of your own code available. If that hurts you are perfectly free to contact the copyright holder and dicker for your own license.

--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
     USE worldnet address!
Reply to
CBFalconer

I'm using a AVR with Codevision and yes it does deal with 32bit unsigned. I am processing Network Time Protocol data from ethernet and therefore require seconds since 1900.

Thanks for all you help!

Wayne

Reply to
Wayne Peacock

Thanks Peter!

over two hours on google found nothing that I could use. I must of been searching for the wrong stuff!

Regards Wayne

Reply to
Wayne Peacock

Wayne Peacock wrote: [...]

Ah. (...reads RFC on NTP...) I wouldn't ever have guessed these guys would still have a hardwired "Y2K" type of problem in the protocol, but they do. NTP will overflow in 2036, and so will your product.

Now, for a normal piece of software I wouldn't let that bother me, but for an embedded system, there could be a non-negligible chance some of your devices will still be in operation in 2036 --- how to you plan on handling that?

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

Have a look for mktime in the NEWLIB sources. They do not have GPL or LGPL restrictions. Might also try the various BSD sources.

Regards

-Bill Knight R O SoftWare

Reply to
Bill Knight

You can always use the trick of checking for the time value < 2**31 and shift the base forward to 2036. This will get you by until 2104 by which time it's someone else's problem!

Reply to
Everett M. Greene

You might also google for Minix. The Minix sources also contain a readable implementation and the license is quite liberal now (like public domain, if I remember correctly).

Guido

Reply to
Guido Muesch

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.