mount_setattr.2: Add a reference to mount_namespaces(7) in discussion of propagation...
[man-pages.git] / man3 / timegm.3
blobb848e83e180e5b5885d6dbe352cf5eabb86208e7
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH TIMEGM 3 2021-03-22 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 timegm, timelocal \- inverses of gmtime and localtime
28 .SH SYNOPSIS
29 .nf
30 .B #include <time.h>
31 .PP
32 .BI "time_t timelocal(struct tm *" tm );
33 .BI "time_t timegm(struct tm *" tm );
34 .PP
35 .fi
36 .RS -4
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .RE
40 .PP
41 .BR timelocal (),
42 .BR timegm ():
43 .nf
44     Since glibc 2.19:
45         _DEFAULT_SOURCE
46     Glibc 2.19 and earlier:
47         _BSD_SOURCE || _SVID_SOURCE
48 .fi
49 .SH DESCRIPTION
50 The functions
51 .BR timelocal ()
52 and
53 .BR timegm ()
54 are the inverses of
55 .BR localtime (3)
56 and
57 .BR gmtime (3).
58 Both functions take a broken-down time and convert it to calendar time
59 (seconds since the Epoch, 1970-01-01 00:00:00 +0000, UTC).
60 The difference between the two functions is that
61 .BR timelocal ()
62 takes the local timezone into account when doing the conversion, while
63 .BR timegm ()
64 takes the input value to be Coordinated Universal Time (UTC).
65 .SH RETURN VALUE
66 On success,
67 these functions return the calendar time (seconds since the Epoch),
68 expressed as a value of type
69 .IR time_t .
70 On error, they return the value
71 .I (time_t)\ \-1
72 and set
73 .I errno
74 to indicate the error.
75 .SH ERRORS
76 .TP
77 .B EOVERFLOW
78 The result cannot be represented.
79 .SH ATTRIBUTES
80 For an explanation of the terms used in this section, see
81 .BR attributes (7).
82 .ad l
83 .nh
84 .TS
85 allbox;
86 lbx lb lb
87 l l l.
88 Interface       Attribute       Value
90 .BR timelocal (),
91 .BR timegm ()
92 T}      Thread safety   MT-Safe env locale
93 .TE
94 .hy
95 .ad
96 .sp 1
97 .SH CONFORMING TO
98 These functions are nonstandard GNU extensions
99 that are also present on the BSDs.
100 Avoid their use.
101 .SH NOTES
103 .BR timelocal ()
104 function is equivalent to the POSIX standard function
105 .BR mktime (3).
106 There is no reason to ever use it.
107 .SH SEE ALSO
108 .BR gmtime (3),
109 .BR localtime (3),
110 .BR mktime (3),
111 .BR tzset (3)