]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/timegm.3
sync
[thirdparty/man-pages.git] / man3 / timegm.3
CommitLineData
fea681da
MK
1.\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
11.\"
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
19.\"
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.TH TIMEGM 3 2001-12-26 "GNU" "Linux Programmer's Manual"
24.SH NAME
25timegm, timelocal \- inverses for gmtime and localtime
26.SH SYNOPSIS
27.nf
28.B #include <time.h>
29.sp
b9f02710 30.BI "time_t timelocal(struct tm *" tm );
fea681da 31.sp
b9f02710 32.BI "time_t timegm(struct tm *" tm );
fea681da
MK
33.SH DESCRIPTION
34The functions
63aa9df0 35.BR timelocal ()
fea681da 36and
63aa9df0 37.BR timegm ()
fea681da
MK
38are the inverses to
39.BR localtime (3)
40and
41.BR gmtime (3).
42.SH NOTES
43These functions are GNU extensions.
44The
63aa9df0 45.BR timelocal ()
fea681da
MK
46function is equivalent to the POSIX standard function
47.BR mktime (3).
48There is no reason to ever use it.
49.LP
50For a portable version of
63aa9df0 51.BR timegm (),
fea681da
MK
52set the
53.B TZ
54environment variable to UTC, call
63aa9df0 55.BR mktime ()
fea681da
MK
56and restore the value of
57.BR TZ .
58Something like
59
60.RS
61.nf
62#include <time.h>
63#include <stdlib.h>
64
41798314
MK
65time_t
66my_timegm(struct tm *tm)
67{
fea681da
MK
68 time_t ret;
69 char *tz;
70
71 tz = getenv("TZ");
72 setenv("TZ", "", 1);
73 tzset();
74 ret = mktime(tm);
75 if (tz)
76 setenv("TZ", tz, 1);
77 else
78 unsetenv("TZ");
79 tzset();
80 return ret;
81}
82.fi
83.RE
a7fadb55
MK
84.SH "CONFORMING TO"
85Not in POSIX.1-2001.
86Present on the BSDs.
fea681da
MK
87.SH "SEE ALSO"
88.BR gmtime (3),
89.BR localtime (3),
90.BR mktime (3),
91.BR tzset (3)