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
Didn't find your answer? Ask the community — no account required.
H
Hans-Bernhard Broeker
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.
G
George
If you can't help shut up!!
George
A
Andrew Jackson
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
G
George
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
B
Bob
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
R
R Adsett
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
G
George
How interesting. An answer!!
Thank you. Bob
D
Darryl Green
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.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.