about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
Diffstat (limited to 'time')
-rw-r--r--time/Makefile2
-rw-r--r--time/mktime.c2
-rw-r--r--time/strftime.c6
-rw-r--r--time/strfxtime.c33
-rw-r--r--time/time.h43
5 files changed, 82 insertions, 4 deletions
diff --git a/time/Makefile b/time/Makefile
index c4945f7e4b..87231d7770 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -32,7 +32,7 @@ routines	:= offtime asctime clock ctime ctime_r difftime	\
 		   tzfile gettimeofday settimeofday adjtime	\
 		   getitimer setitimer				\
 		   stime dysize timegm ftime			\
-		   strptime getdate
+		   strptime getdate strfxtime
 
 others	:= ap zdump zic
 tests	:= test_time clocktest test-tz
diff --git a/time/mktime.c b/time/mktime.c
index 1573cc79a9..7a94c21244 100644
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -194,7 +194,7 @@ __mktime_internal (tp, convert, offset)
 
   /* The maximum number of probes (calls to CONVERT) should be enough
      to handle any combinations of time zone rule changes, solar time,
-     and leap seconds.  Posix.1 prohibits leap seconds, but some hosts
+     and leap seconds.  POSIX.1 prohibits leap seconds, but some hosts
      have them anyway.  */
   int remaining_probes = 4;
 
diff --git a/time/strftime.c b/time/strftime.c
index 8d94dcdf60..e66a444d40 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -883,6 +883,11 @@ my_strftime (s, maxsize, format, tp)
 	  cpy (buf + sizeof (buf) - bufp, bufp);
 	  break;
 
+	case 'F':
+	  if (modifier != 0)
+	    goto bad_format;
+	  subfmt = "%Y-%m-%d";
+	  goto subformat;
 
 	case 'H':
 	  if (modifier == 'E')
@@ -1029,6 +1034,7 @@ my_strftime (s, maxsize, format, tp)
 	  add (1, *p = '\t');
 	  break;
 
+	case 'f':
 	case 'u':		/* POSIX.2 extension.  */
 	  DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1);
 
diff --git a/time/strfxtime.c b/time/strfxtime.c
new file mode 100644
index 0000000000..eb563ae52e
--- /dev/null
+++ b/time/strfxtime.c
@@ -0,0 +1,33 @@
+/* ISO C extended string formatting.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <time.h>
+
+/* The ISO C 9X standard extended the `struct tm' structure to contain some
+   more information necessary for the new formats.  But the struct format
+   we used so far already contains the information and since the `struct tm'
+   and `struct tmx' structures match exactly in the first part.  So we can
+   simply use `strftime' to implement `strfxtime'.  */
+size_t
+strfxtime (char *s, size_t maxsize, const char *format,
+	   const struct tmx *timeptr)
+{
+  return strftime (s, maxsize, format, (const struct tm *) timeptr);
+}
diff --git a/time/time.h b/time/time.h
index 184f4eda10..f60599d2cb 100644
--- a/time/time.h
+++ b/time/time.h
@@ -95,6 +95,13 @@ struct timespec
 #undef	__need_timespec
 
 
+/* Value used for `tm_' field in `struct tmx' if describing the local
+   time.  */
+#define _LOCALTIME		(0x7fffffff)
+
+/* Value used for `tm_leapsecond' field if the number cannot be computed.  */
+#define _NO_LEAP_SECONDS	(0x7fffffff)
+
 
 #ifdef	_TIME_H
 /* Used by other time functions.  */
@@ -119,10 +126,36 @@ struct tm
 # endif
 };
 
-#endif /* <time.h> included.  */
+#ifdef __USE_ISOC9X
+/* Extended form of `struct tm' defined in ISO C 9X.  */
+struct tmx
+{
+  int tm_sec;			/* Seconds.	[0-60] (1 leap second) */
+  int tm_min;			/* Minutes.	[0-59] */
+  int tm_hour;			/* Hours.	[0-23] */
+  int tm_mday;			/* Day.		[1-31] */
+  int tm_mon;			/* Month.	[0-11] */
+  int tm_year;			/* Year	- 1900.  */
+  int tm_wday;			/* Day of week.	[0-6] */
+  int tm_yday;			/* Days in year.[0-365]	*/
+  int tm_isdst;			/* DST.		[-1/0/1]*/
+
+# ifdef	__USE_BSD
+  long int tm_gmtoff;		/* Seconds east of UTC.  */
+# else
+  long int __tm_gmtoff;		/* Seconds east of UTC.  */
+# endif
+  __const char *__tm_zonestr;	/* Timezone abbreviation.  */
+
+  int tm_version;		/* Version number.  */
+  int tm_zone;			/* Minutes offset from UTC [-1439-1439] */
+  int tm_leapsecs;		/* Number of leap seconds applied.  */
+  void *tm_ext;			/* Extension block.  */
+  size_t tm_extlen;		/* Size of the extension block.  */
+};
+#endif
 
 
-#ifdef	_TIME_H
 /* Time used by the program so far (user time + system time).
    The result / CLOCKS_PER_SECOND is program time in seconds.  */
 extern clock_t clock __P ((void));
@@ -145,6 +178,12 @@ extern time_t __mktime_internal __P ((struct tm *__tp,
 							    struct tm *),
 				      time_t *__offset));
 
+#ifdef __USE_ISOC9X
+/* Return the `time_t' representation of TP and normalize TP, taking
+   account for the extra members in `struct tmx'.  */
+extern time_t mkxtime __P ((struct tmx *__tp));
+#endif
+
 
 /* Format TP into S according to FORMAT.
    Write no more than MAXSIZE characters and return the number