Debian Codegraph @

upstream/debian-trixie/man3/timegm.3

raw
1 '\" t
2 .\" Copyright (C) 2001 Andries Brouwer <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH timegm 3 2024-05-02 "Linux man-pages 6.9.1"
7 .SH NAME
8 timegm, timelocal \- inverses of gmtime and localtime
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ", " \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <time.h>
15 .P
16 .BI "[[deprecated]] time_t timelocal(struct tm *" tm );
17 .BI "time_t timegm(struct tm *" tm );
18 .P
19 .fi
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
25 .BR timelocal (),
26 .BR timegm ():
27 .nf
28 Since glibc 2.19:
29 _DEFAULT_SOURCE
30 glibc 2.19 and earlier:
31 _BSD_SOURCE || _SVID_SOURCE
32 .fi
33 .SH DESCRIPTION
34 The functions
35 .BR timelocal ()
36 and
37 .BR timegm ()
38 are the inverses of
39 .BR localtime (3)
40 and
41 .BR gmtime (3).
42 Both functions take a broken-down time and convert it to calendar time
43 (seconds since the Epoch, 1970-01-01 00:00:00 +0000, UTC).
44 The difference between the two functions is that
45 .BR timelocal ()
46 takes the local timezone into account when doing the conversion, while
47 .BR timegm ()
48 takes the input value to be Coordinated Universal Time (UTC).
49 .SH RETURN VALUE
50 On success,
51 these functions return the calendar time (seconds since the Epoch),
52 expressed as a value of type
53 .IR time_t .
54 On error, they return the value
55 .I (time_t)\ \-1
56 and set
57 .I errno
58 to indicate the error.
59 .SH ERRORS
60 .TP
61 .B EOVERFLOW
62 The result cannot be represented.
63 .SH ATTRIBUTES
64 For an explanation of the terms used in this section, see
65 .BR attributes (7).
66 .TS
67 allbox;
68 lbx lb lb
69 l l l.
70 Interface Attribute Value
71 T{
72 .na
73 .nh
74 .BR timelocal (),
75 .BR timegm ()
76 T} Thread safety MT-Safe env locale
77 .TE
78 .SH STANDARDS
79 BSD.
80 .SH HISTORY
81 GNU, BSD.
82 .P
83 The
84 .BR timelocal ()
85 function is equivalent to the POSIX standard function
86 .BR mktime (3).
87 There is no reason to ever use it.
88 .SH SEE ALSO
89 .BR gmtime (3),
90 .BR localtime (3),
91 .BR mktime (3),
92 .BR tzset (3)