| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- converts a tm structure to a calendar time
#include <time.h>time_tmktime(struct tm *timeptr);
Themktime() function converts the time represented by thetm structure pointedto bytimeptr into a calendar time (the number of secondssince 00:00:00 UTC, January 1, 1970).
Thetm structure contains the following members:
int tm_sec; /* seconds after the minute [0, 60] */int tm_min; /* minutes after the hour [0, 59] */int tm_hour; /* hour since midnight [0, 23] */int tm_mday; /* day of the month [1, 31] */int tm_mon; /* months since January [0, 11] */int tm_year; /* years since 1900 */int tm_wday; /* days since Sunday [0, 6] */int tm_yday; /* days since January 1 [0, 365] */int tm_isdst; /* flag for daylight savings time */
In addition to computing the calendar time,mktime() normalizes the suppliedtmstructure. The original values of thetm_wday andtm_yday components of thestructure are ignored, and the original values of the other components are notrestricted to the ranges indicated in the definition of the structure. Onsuccessful completion, the values of thetm_wday andtm_yday components are setappropriately, and the other components are set to represent the specified calendar time,but with their values forced to be within the appropriate ranges. Thefinal value oftm_mday is not set untiltm_mon andtm_year aredetermined.
Thetm_year member must be for year 1901 or later. Calendar timesbefore 20:45:52 UTC, December 13, 1901 or after 03:14:07 UTC, January19, 2038 cannot be represented. Portable applications should not try to createdates before 00:00:00 UTC, January 1, 1970 or after 00:00:00 UTC, January 1,2038.
The original values of the components may be either greater than orless than the specified range. For example, atm_hour of -1 means1 hour before midnight,tm_mday of 0 means the day preceding thecurrent month, andtm_mon of -2 means 2 months before January oftm_year.
Iftm_isdst is positive, the original values are assumed to be inthe alternate timezone. If it turns out that the alternate timezone isnot valid for the computed calendar time, then the components are adjustedto the main timezone. Likewise, iftm_isdst is zero, the original values areassumed to be in the main timezone and are converted to thealternate timezone if the main timezone is not valid. Iftm_isdstis negative,mktime() attempts to determine whether the alternate timezone is ineffect for the specified time.
Local timezone information is used as ifmktime() had calledtzset(). Seectime(3C).
If the calendar time can be represented in an object of typetime_t,mktime() returns the specified calendar time without changingerrno. If thecalendar time cannot be represented, the function returns the value (time_t)-1 and setserrno to indicate the error.
Themktime() function will fail if:
The date represented by the inputtm struct cannot be represented in atime_t. Note that theerrno setting may change if future revisions to the standards specify a different value.
Themktime() function is MT-Safe in multithreaded applications, as long asno user-defined function directly modifies one of the following variables:timezone,altzone,daylight, andtzname. Seectime(3C).
Note that -1 can be a valid return value for the timethat is one second before the Epoch. The user should clearerrno before callingmktime(). Ifmktime() then returns -1, the user shouldcheckerrno to determine whether or not an error actually occurred.
Themktime() function assumes Gregorian dates. Times before the adoption ofthe Gregorian calendar will not match historical records.
Example 1 Sample code usingmktime().
What day of the week is July 4, 2001?
#include <stdio.h>#include <time.h>static char *const wday[ ] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "-unknown-"};struct tm time_str;/* . . .*/time_str.tm_year = 2001 - 1900;time_str.tm_mon = 7 - 1;time_str.tm_mday = 4;time_str.tm_hour = 0;time_str.tm_min = 0;time_str.tm_sec = 1;time_str.tm_isdst = -1;if (mktime(&time_str)== -1) time_str.tm_wday=7;printf("%s\n", wday[time_str.tm_wday]);Seeattributes(5) for descriptions of the following attributes:
|
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |