From: Juliusz Chroboczek <Juliusz.Chroboczek@pps.jussieu.fr>
To: git@vger.kernel.org
Subject: Re: Trying to use AUTHOR_DATE
Date: Sat, 30 Apr 2005 23:59:44 +0200 [thread overview]
Message-ID: <7ism18exin.fsf@lanthane.pps.jussieu.fr> (raw)
In-Reply-To: <Pine.LNX.4.58.0504301322130.2296@ppc970.osdl.org> (Linus Torvalds's message of "Sat, 30 Apr 2005 13:32:35 -0700 (PDT)")
Hi,
Here's the code I'm using in darcs-git (copied from Polipo, another
project of mine). You're welcome to use it in any way you see fit.
sprintf_a is defined as strdup of sprintf.
Juliusz
#if defined __GLIBC__
#define HAVE_TM_GMTOFF
#define HAVE_SETENV
#ifndef __UCLIBC__
#define HAVE_TIMEGM
#endif
#endif
#if defined(__linux__) && (__GNU_LIBRARY__ == 1)
/* Linux libc 5 */
#define HAVE_TIMEGM
#define HAVE_SETENV
#endif
#ifdef BSD
#define HAVE_TM_GMTOFF
#define HAVE_SETENV
#endif
#ifdef __CYGWIN__
#define HAVE_SETENV
#endif
#if _POSIX_VERSION >= 200112L
#define HAVE_SETENV
#endif
#define HAVE_TZSET
/* Like mktime(3), but UTC rather than local time */
#if defined(HAVE_TIMEGM)
time_t
mktime_gmt(struct tm *tm)
{
return timegm(tm);
}
#elif defined(HAVE_TM_GMTOFF)
time_t
mktime_gmt(struct tm *tm)
{
time_t t;
struct tm *ltm;
t = mktime(tm);
if(t < 0)
return -1;
ltm = localtime(&t);
if(ltm == NULL)
return -1;
return t + ltm->tm_gmtoff;
}
#elif defined(HAVE_TZSET)
#ifdef HAVE_SETENV
/* Taken from the Linux timegm(3) man page. */
time_t
mktime_gmt(struct tm *tm)
{
time_t t;
char *tz;
tz = getenv("TZ");
setenv("TZ", "", 1);
tzset();
t = mktime(tm);
if(tz)
setenv("TZ", tz, 1);
else
unsetenv("TZ");
tzset();
return t;
}
#else
time_t
mktime_gmt(struct tm *tm)
{
time_t t;
char *tz;
static char *old_tz = NULL;
tz = getenv("TZ");
putenv("TZ=");
tzset();
t = mktime(tm);
if(old_tz)
free(old_tz);
if(tz)
old_tz = sprintf_a("TZ=%s", tz);
else
old_tz = strdup("TZ"); /* XXX - non-portable? */
if(old_tz)
putenv(old_tz);
tzset();
return t;
}
#endif
#else
#error no mktime_gmt implementation on this platform
#endif
next prev parent reply other threads:[~2005-04-30 21:54 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-30 3:44 Trying to use AUTHOR_DATE Luck, Tony
2005-04-30 3:49 ` H. Peter Anvin
2005-04-30 4:02 ` Linus Torvalds
2005-04-30 4:22 ` Linus Torvalds
2005-04-30 4:32 ` Russ Allbery
2005-04-30 8:02 ` David Woodhouse
2005-04-30 10:40 ` Edgar Toernig
2005-04-30 18:10 ` Russ Allbery
2005-04-30 20:32 ` Linus Torvalds
2005-04-30 21:59 ` Juliusz Chroboczek [this message]
2005-04-30 22:54 ` Edgar Toernig
2005-04-30 23:18 ` Linus Torvalds
2005-05-01 16:46 ` Linus Torvalds
2005-05-01 16:57 ` Randy.Dunlap
2005-05-01 17:23 ` Edgar Toernig
2005-04-30 5:43 ` Junio C Hamano
2005-04-30 10:53 ` Edgar Toernig
2005-04-30 11:13 ` David Woodhouse
2005-04-30 12:08 ` Kay Sievers
2005-04-30 12:13 ` David Woodhouse
2005-04-30 12:49 ` Edgar Toernig
2005-04-30 12:59 ` David Woodhouse
2005-04-30 13:22 ` Edgar Toernig
2005-05-02 22:10 ` Krzysztof Halasa
2005-05-02 22:26 ` H. Peter Anvin
2005-05-02 23:30 ` Krzysztof Halasa
2005-05-02 23:32 ` H. Peter Anvin
2005-05-03 0:30 ` Krzysztof Halasa
2005-05-03 0:38 ` H. Peter Anvin
2005-04-30 23:14 ` H. Peter Anvin
2005-04-30 4:50 ` Edgar Toernig
-- strict thread matches above, loose matches on Subject: below --
2005-04-30 5:28 Luck, Tony
2005-04-30 23:14 ` H. Peter Anvin
2005-04-29 23:14 tony.luck
2005-04-29 23:35 ` H. Peter Anvin
2005-04-30 0:21 ` tony.luck
2005-04-30 3:23 ` Edgar Toernig
2005-04-30 3:47 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7ism18exin.fsf@lanthane.pps.jussieu.fr \
--to=juliusz.chroboczek@pps.jussieu.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.