logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

mktime.3p (5120B)


  1. '\" et
  2. .TH MKTIME "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. mktime
  12. \(em convert broken-down time into time since the Epoch
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <time.h>
  17. .P
  18. time_t mktime(struct tm *\fItimeptr\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fImktime\fR()
  27. function shall convert the broken-down time, expressed as local time,
  28. in the structure pointed to by
  29. .IR timeptr ,
  30. into a time since the Epoch value with the same encoding as that of the
  31. values returned by
  32. \fItime\fR().
  33. The original values of the
  34. .IR tm_wday
  35. and
  36. .IR tm_yday
  37. components of the structure shall be ignored, and the original values
  38. of the other components shall not be restricted to the ranges
  39. described in
  40. .IR <time.h> .
  41. .P
  42. A positive or 0 value for
  43. .IR tm_isdst
  44. shall cause
  45. \fImktime\fR()
  46. to presume initially that Daylight Savings Time, respectively, is or is
  47. not in effect for the specified time. A negative value for
  48. .IR tm_isdst
  49. shall cause
  50. \fImktime\fR()
  51. to attempt to determine whether Daylight Savings Time is in effect for
  52. the specified time.
  53. .P
  54. Local timezone information shall be set as though
  55. \fImktime\fR()
  56. called
  57. \fItzset\fR().
  58. .P
  59. The relationship between the
  60. .BR tm
  61. structure (defined in the
  62. .IR <time.h>
  63. header) and the time in seconds since the Epoch is that the result
  64. shall be as specified in the expression given in the definition of
  65. seconds since the Epoch (see the Base Definitions volume of POSIX.1\(hy2017,
  66. .IR "Section 4.16" ", " "Seconds Since the Epoch")
  67. corrected for timezone and any seasonal time adjustments, where the
  68. names other than
  69. .IR tm_yday
  70. in the structure and in the expression correspond, and the
  71. .IR tm_yday
  72. value used in the expression is the day of the year from 0 to 365
  73. inclusive, calculated from the other
  74. .BR tm
  75. structure members specified in
  76. .IR <time.h>
  77. (excluding
  78. .IR tm_wday ).
  79. .P
  80. Upon successful completion, the values of the
  81. .IR tm_wday
  82. and
  83. .IR tm_yday
  84. components of the structure shall be set appropriately, and the other
  85. components shall be set to represent the specified time since the Epoch,
  86. but with their values forced to the ranges indicated in the
  87. .IR <time.h>
  88. entry; the final value of
  89. .IR tm_mday
  90. shall not be set until
  91. .IR tm_mon
  92. and
  93. .IR tm_year
  94. are determined.
  95. .SH "RETURN VALUE"
  96. The
  97. \fImktime\fR()
  98. function shall return the specified time since the Epoch encoded as
  99. a value of type
  100. .BR time_t .
  101. If the time since the Epoch cannot be represented, the function shall
  102. return the value (\fBtime_t\fP)\-1
  103. and set
  104. .IR errno
  105. to indicate the error.
  106. .SH ERRORS
  107. The
  108. \fImktime\fR()
  109. function shall fail if:
  110. .TP
  111. .BR EOVERFLOW
  112. The result cannot be represented.
  113. .LP
  114. .IR "The following sections are informative."
  115. .SH "EXAMPLES"
  116. What day of the week is July 4, 2001?
  117. .sp
  118. .RS 4
  119. .nf
  120. #include <stdio.h>
  121. #include <time.h>
  122. .P
  123. struct tm time_str;
  124. .P
  125. char daybuf[20];
  126. .P
  127. int main(void)
  128. {
  129. time_str.tm_year = 2001 \(em 1900;
  130. time_str.tm_mon = 7 \(em 1;
  131. time_str.tm_mday = 4;
  132. time_str.tm_hour = 0;
  133. time_str.tm_min = 0;
  134. time_str.tm_sec = 1;
  135. time_str.tm_isdst = -1;
  136. if (mktime(&time_str) == -1)
  137. (void)puts("-unknown-");
  138. else {
  139. (void)strftime(daybuf, sizeof(daybuf), "%A", &time_str);
  140. (void)puts(daybuf);
  141. }
  142. return 0;
  143. }
  144. .fi
  145. .P
  146. .RE
  147. .SH "APPLICATION USAGE"
  148. None.
  149. .SH RATIONALE
  150. None.
  151. .SH "FUTURE DIRECTIONS"
  152. None.
  153. .SH "SEE ALSO"
  154. .IR "\fIasctime\fR\^(\|)",
  155. .IR "\fIclock\fR\^(\|)",
  156. .IR "\fIctime\fR\^(\|)",
  157. .IR "\fIdifftime\fR\^(\|)",
  158. .IR "\fIgmtime\fR\^(\|)",
  159. .IR "\fIlocaltime\fR\^(\|)",
  160. .IR "\fIstrftime\fR\^(\|)",
  161. .IR "\fIstrptime\fR\^(\|)",
  162. .IR "\fItime\fR\^(\|)",
  163. .IR "\fItzset\fR\^(\|)",
  164. .IR "\fIutime\fR\^(\|)"
  165. .P
  166. The Base Definitions volume of POSIX.1\(hy2017,
  167. .IR "Section 4.16" ", " "Seconds Since the Epoch",
  168. .IR "\fB<time.h>\fP"
  169. .\"
  170. .SH COPYRIGHT
  171. Portions of this text are reprinted and reproduced in electronic form
  172. from IEEE Std 1003.1-2017, Standard for Information Technology
  173. -- Portable Operating System Interface (POSIX), The Open Group Base
  174. Specifications Issue 7, 2018 Edition,
  175. Copyright (C) 2018 by the Institute of
  176. Electrical and Electronics Engineers, Inc and The Open Group.
  177. In the event of any discrepancy between this version and the original IEEE and
  178. The Open Group Standard, the original IEEE and The Open Group Standard
  179. is the referee document. The original Standard can be obtained online at
  180. http://www.opengroup.org/unix/online.html .
  181. .PP
  182. Any typographical or formatting errors that appear
  183. in this page are most likely
  184. to have been introduced during the conversion of the source files to
  185. man page format. To report such errors, see
  186. https://www.kernel.org/doc/man-pages/reporting_bugs.html .