Time Stuff

In Time.h there is a structure defined for time settings. I'm building an embedded system that has a Real Time Clock but it's not PC compatible.

My question is:

I don't some elements of the structure such as day of the week or day of the year, but I do know year,month,date,hour,min,sec. Does the language support filling in the missing elements. And is there a consistency check for that time structure.

Thanks George

Reply to
George
Loading thread data ...

You're quite confused.

1) "The language" has nothing particular to do with this. Which is just as well, since you forgot to mention what the language _is_.

2) is part of the Standard C runtime library, and therefore its behaviour is defined primarily by the C Standard, and secondarily by your compiler toolchain's maker (which you forgot to specify, too). Did you consult your documentation? What did it say?

3) That your system is not a PC is irrelevant. The only thing that matters is whether your C platform is a "hosted environment", at least as far as is concerned, or not.
--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

If you can't help shut up!!

George

Reply to
George

Hans-Bernard was being helpful. He pointed out that you hadn't told us:

  • Which language * Which platform * Which toolchain

Without which only general advice can be given.

On many embedded systems you have to provide the implementation of "standard" library routines either through hooks provided by the compiler/toolchain author or directly as a complete routine. Since the embedded system is under your control you might choose to:

  • Completely ignore the elements in which you are not interested * Provide fixed values for those uninteresting elements

It does depend though whether you are relying on thrid-party source for some time related functions.

Andrew

Reply to
Andrew Jackson

OK. Let's see if either you or Hans-Bernard can reply with an answer or just more babble.

Language: C Platform: One you are an expert with. You can pick. Toolchain: Any one you choose.

Please tell us which Platform and Toolchain you've selected to talk about and then answer the questins, if you can.

George

Reply to
George

secondarily

too).

least

some

OK. The answers to your original questions are: No, and No. Normally, I would include an explaination, but I fear you would consider it "just more babble".

Bob

Reply to
Bob

They really are trying to help you know.

Extrapolating from what you have written.

- You have some hardware (micro, memory, RTC) of unknown origin - You have a tool chain of unknown brand and library support - You want to provide standard time functions

What you haven't provided is - which standard? - what functions do you wish to provide? - what support already exists?

Assuming that the answers to above questions are ANSI standard, all and none respectively, the first thing you need is a reference for the C standard library. Then you could consider writing the functions yourself or porting newlib or buying a library.

What are you trying to accomplish? Familiarizing yourself with library implementation? Determine how long your board has been on? Provide a yet another blinking clock for people to set? Port a piece of code that makes use of the time routines? Provide support for others?

All of these may have different answers and they will change depending on what support already exists.

I suspect what you need is to start with something like "The Standard C Library" by Plauger

Robert

Reply to
R Adsett

How interesting. An answer!!

Thank you. Bob

Reply to
George

getdate will fill them in.

No but getdate will check its input.

Of course, this is completely useless advice, because getdate, struct tm and friends are all part of a bigger picture. There have been and continue to be variations on that picture. The advice above is applicable to a working posix conformant system, which you don't, by definition, have. Others seem to have wanted to help you to make (part of) one or find out which part you have in order to solve your problem, instead of just telling you how it should work.

Have a nice day Darryl.

Reply to
Darryl Green

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.