EmbeddedRelated.com
Forums

Time Stuff

Started by George July 5, 2004
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
George <george.martin@att.net> wrote:

> 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.
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) <time.h> 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 <time.h> is concerned, or not. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> wrote in message news:<2ku9m9F6lsotU2@uni-berlin.de>...
> George <george.martin@att.net> wrote: > > > 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. > > 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) <time.h> 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 <time.h> is concerned, or not.
If you can't help shut up!! George
> > > > 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) <time.h> 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 <time.h> is concerned, or not. > > > If you can't help shut up!! >
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
"Andrew Jackson" <alj@nospam.com> wrote in message news:<3sadnQsPMaQGIHfdRVn-ug@eclipse.net.uk>...
> > > > > > 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) <time.h> 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 <time.h> is concerned, or not. > > > > > > If you can't help shut up!! > > > 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
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
"George" <george.martin@att.net> wrote in message
news:e9d879fa.0407070502.2c7d3637@posting.google.com...
> "Andrew Jackson" <alj@nospam.com> wrote in message
news:<3sadnQsPMaQGIHfdRVn-ug@eclipse.net.uk>...
> > > > > > > > 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) <time.h> 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 <time.h> is concerned, or not. > > > > > > > > > If you can't help shut up!! > > > > > 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 > > 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
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
In article <e9d879fa.0407070502.2c7d3637@posting.google.com>, 
george.martin@att.net says...
> 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 >
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
"Bob" <SkiBoyBob@excite.com> wrote in message news:<10eo6ilimfs452f@corp.supernews.com>...
> "George" <george.martin@att.net> wrote in message > news:e9d879fa.0407070502.2c7d3637@posting.google.com... > > "Andrew Jackson" <alj@nospam.com> wrote in message > news:<3sadnQsPMaQGIHfdRVn-ug@eclipse.net.uk>... > > > > > > > > > > 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) <time.h> 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 <time.h> is concerned, or not. > > > > > > > > > > > > If you can't help shut up!! > > > > > > > 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 > > > > 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 > > 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
How interesting. An answer!! Thank you. Bob
george.martin@att.net (George) wrote in message news:<e9d879fa.0407051503.66fdc2df@posting.google.com>...
> 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.
getdate will fill them in.
> And is there a > consistency check for that time structure.
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.