Sunday 13 November 2011

Why are so many different time standards defined? in C programming

Why are so many different time standards defined?

Depending on the computer and compiler you are using, you might find many different time standards defined. Although having so many time standards might be convenient, it obviously took a lot of time to write all of them. And storing them all is taking up extra space on your computer’s hard disk. Why bother? There are several reasons.

First, C is intended to be a portable language. Thus, a C program written on one make of computer should run on another. Often, functions that were particular to one system have had to be added to the C language when it was created on a new system. Later, when C programs need to be moved from that system to another, it is often easiest to add the specific commands to the target system. In this way, several versions of the same function could eventually be integrated into the C language. This has happened several times with the time function.

Second, there are several different possible uses for times (and dates). You might want to count time in
seconds, you might want to count time as starting from a specified time and date, or you might want to count time in the smallest interval possible to ensure that your measure of time will be as accurate as possible. There is no best way to measure time. When you begin a program that involves time, you must examine the functions available to you and determine which are best suited to your purpose. If you are handling time in various ways, you might want to use several different time formats and functions. In this case, you might be glad that there are so many formats for time and that there was one to fulfill your needs.

Cross Reference:

XIII.1: How can I store a date in a single number? Are there any standards for this?
XIII.2: How can I store time as a single integer? Are there any standards for this?
XIII.4: What is the best way to store the date?
XIII.5: What is the best way to store the time?

No comments:

Post a Comment