aboutsummaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-08-26 10:28:45 +0000
committerUlrich Drepper <drepper@redhat.com>1996-08-26 10:28:45 +0000
commitdcf0671d905200c449f92ead6cf43c184637a0d5 (patch)
tree91dc217311db41e89545d487b991865a6433205e /time
parent4884d0f03c5a3b3d2459655e76fa2d0684d389dc (diff)
downloadglibc-dcf0671d905200c449f92ead6cf43c184637a0d5.tar
glibc-dcf0671d905200c449f92ead6cf43c184637a0d5.tar.gz
glibc-dcf0671d905200c449f92ead6cf43c184637a0d5.tar.bz2
glibc-dcf0671d905200c449f92ead6cf43c184637a0d5.zip
handle password file locking.cvs/libc-960826
Diffstat (limited to 'time')
-rw-r--r--time/gmtime.c12
-rw-r--r--time/strftime.c40
2 files changed, 32 insertions, 20 deletions
diff --git a/time/gmtime.c b/time/gmtime.c
index 93fba659be..364b4c9262 100644
--- a/time/gmtime.c
+++ b/time/gmtime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#include <ansidecl.h>
#include <stddef.h>
#include <time.h>
@@ -25,16 +24,19 @@ extern struct tm _tmbuf;
/* Return the `struct tm' representation of *T in UTC. */
struct tm *
-DEFUN(gmtime, (t), CONST time_t *t)
+gmtime (t)
+ const time_t *t;
{
return __gmtime_r (t, &_tmbuf);
}
+
/* Return the `struct tm' representation of *T in UTC,
using *TP to store the result. */
struct tm *
-DEFUN(__gmtime_r, (t, tp),
- CONST time_t *t AND struct tm *tp)
+__gmtime_r (t, tp)
+ const time_t *t;
+ struct tm *tp;
{
__offtime (t, 0L, tp);
diff --git a/time/strftime.c b/time/strftime.c
index 214f82f488..129fd1412c 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -470,27 +470,37 @@ strftime (s, maxsize, format, tp)
case 'z':
{
struct tm tml = *tp;
- time_t t = mktime (&tml);
struct tm tmg;
+ time_t t;
+ time_t offset = 0;
int diff;
- tml = *localtime (&t); /* Canonicalize the local time. */
- tmg = *gmtime (&t);
+ t = __mktime_internal (&tml, __localtime_r, &offset);
- /* Compute the difference. */
- diff = tml.tm_min - tmg.tm_min;
- diff += 60 * (tml.tm_hour - tmg.tm_hour);
-
- if (tml.tm_mon != tmg.tm_mon)
+ /* Canonicalize the local time. */
+ if (t == (time_t) -1 || __localtime_r (&t, &tml) == NULL)
+ /* We didn't managed to get the local time. Assume it
+ GMT as a reasonable default value. */
+ diff = 0;
+ else
{
- /* We assume no timezone differs from UTC by more than
- +- 23 hours. This should be safe. */
- if (tmg.tm_mday == 1)
- tml.tm_mday = 0;
- else /* tml.tm_mday == 1 */
- tmg.tm_mday = 0;
+ __gmtime_r (&t, &tmg);
+
+ /* Compute the difference. */
+ diff = tml.tm_min - tmg.tm_min;
+ diff += 60 * (tml.tm_hour - tmg.tm_hour);
+
+ if (tml.tm_mon != tmg.tm_mon)
+ {
+ /* We assume no timezone differs from UTC by more
+ than +- 23 hours. This should be safe. */
+ if (tmg.tm_mday == 1)
+ tml.tm_mday = 0;
+ else /* tml.tm_mday == 1 */
+ tmg.tm_mday = 0;
+ }
+ diff += 1440 * (tml.tm_mday - tmg.tm_mday);
}
- diff += 1440 * (tml.tm_mday - tmg.tm_mday);
if (diff < 0)
{