![]() |
C - Entwicklung Bibliotheks-Funktionen: Datum und Zeit Homepage von PS-Trainer - C-Entwicklung - Bibliotheken - an PS-Trainer |
|
| Time Management | Use these functions to get the current time and convert, adjust, and store it as necessary. | ||||||||||||
| Get the time |
|
||||||||||||
| Convert date and / or time |
|
||||||||||||
| Other date & time functions |
|
||||||||||||
| Time Management Use these functions to get the current time and convert, adjust, and store it as necessary. The current time is the system time. The _ftime and localtime routines use the TZ environment variable. If TZ is not set, the run-time library attempts to use the time-zone information specified by the operating system. If this information is unavailable, these functions use the default value of PST8PDT. For more information on TZ, see _tzset; also see _daylight, timezone, and _tzname. Time Routines. Note In all versions of Microsoft C/C++ except Microsoft C/C++ version 7.0, and in all versions of Microsoft Visual C++, the time function returns the current time as the number of seconds elapsed since midnight on January 1, 1970. In Microsoft C/C++ version 7.0, time returned the current time as the number of seconds elapsed since midnight on December 31, 1899. |
||||||||||||||||||||||||||||||||
|
| difftime Finds the difference between two times. double difftime( time_t timer1, time_t timer0 );
Remarks The difftime function computes the difference between the two supplied time values timer0 and timer1. Subject: Floating-Point Support Routines, Time Management Routines Keywords: See also time |
||||||
| Return Value difftime returns the elapsed time in seconds, from timer0 to timer1. The value returned is a double-precision floating-point number. Parameters
|
||||||
|
Example #include <stdio.h> void main( void ) printf( "Multiplying
2 floating point numbers 10 million times...\n" ); elapsed_time = difftime( finish,
start ); Program takes 2 seconds. |
| clock Calculates the processor time used by the calling process. clock_t clock( void );
Remarks The clock function tells how much processor time the calling process has used. The time in seconds is approximated by dividing the clock return value by the value of the CLOCKS_PER_SEC constant. In other words, clock returns the number of processor timer ticks that have elapsed. A timer tick is approximately equal to 1/CLOCKS_PER_SEC second. In versions of Microsoft C before 6.0, the CLOCKS_PER_SEC constant was called CLK_TCK. Subject: Time Management Routines Keywords: See also difftime, time |
||||||
| Return Value clock returns the number of clock ticks of elapsed processor time. The returned value is the product of the amount of time that has elapsed since the start of a process and the value of the CLOCKS_PER_SEC constant. If the amount of elapsed time is unavailable, the function returns 1, cast as a clock_t. |
||||||
|
Example #include <stdio.h> void sleep( clock_t wait ); void main( void ) /* Delay for a specified time.
*/ /* Measure the duration of
an event. */ /* Pauses for a specified number
of milliseconds. */ |
| _tzset Sets time environment variables. void _tzset( void );
Remarks The _tzset function uses the current setting of the environment variable TZ to assign values to three global variables: _daylight, _timezone, and _tzname. These variables are used by the _ftime and localtime functions to make corrections from coordinated universal time (UTC) to local time, and by the time function to compute UTC from system time. Use the following syntax to set the TZ environment variable: set TZ=tzn[+ | ]hh[:mm[:ss] ][dzn]
For example, to set the TZ environment variable to correspond to the current time zone in Germany, you can use one of the following statements: set TZ=GST1GDT set TZ=GST+1GDT These strings use GST to indicate German standard time, assume that Germany is one hour ahead of UTC, and assume that daylight savings time is in effect. If the TZ value is not set, _tzset attempts to use the time zone information specified by the operating system. Under Windows NT and Windows 95, this information is specified in the Control Panel's Date/Time application. If _tzset cannot obtain this information, it uses PST8PDT by default, which signifies the Pacific time zone. Based on the TZ environment variable value, the following values are assigned to the global variables _daylight, _timezone, and _tzname when _tzset is called:
The default values shown in the preceding table for _daylight and the _tzname array correspond to "PST8PDT." If the DST zone is omitted from the TZ environmental variable, the value of _daylight is 0 and the _ftime, gmtime, and localtime functions return 0 for their DST flags. Subject: Time Management RoutinesTime Management Routines Keywords: See also asctime, _ftime, gmtime, localtime, time, _utime |
|||||||||||||||||||||||||||||||
| Return Value None |
|||||||||||||||||||||||||||||||
|
Example #include <time.h> void main( void ) |
| Aktuelle Daten dieser Seite | Letzte Änderung: |
| |