add System V/P1003.2 formats
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 13 Mar 1989 05:09:32 +0000 (21:09 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 13 Mar 1989 05:09:32 +0000 (21:09 -0800)
SCCS-vsn: lib/libc/string/strftime.c 5.2
SCCS-vsn: lib/libc/string/strftime.3 5.2

usr/src/lib/libc/string/strftime.3
usr/src/lib/libc/string/strftime.c

index 2328b91..3bc9c42 100644 (file)
@@ -13,7 +13,7 @@
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.\"    @(#)strftime.3  5.1 (Berkeley) %G%
+.\"    @(#)strftime.3  5.2 (Berkeley) %G%
 .\"
 .TH STRFTIME 3 "%Q"
 .AT 3
 .\"
 .TH STRFTIME 3 "%Q"
 .AT 3
@@ -72,13 +72,16 @@ is the first three characters.
 .B %B
 is replaced by the full month name.
 .TP
 .B %B
 is replaced by the full month name.
 .TP
-.B %b
+.B %b or %h
 is replaced by the abbreviated month name, where the abbreviation is
 the first three characters.
 .TP
 .B %c
 is equivalent to ``%a %b %d %X %Z %Y''.
 .TP
 is replaced by the abbreviated month name, where the abbreviation is
 the first three characters.
 .TP
 .B %c
 is equivalent to ``%a %b %d %X %Z %Y''.
 .TP
+.B %D
+is replaced by the date in the format ``mm/dd/yy''.
+.TP
 .B %d
 is replaced by the day of the month as a decimal number (01-31).
 .TP
 .B %d
 is replaced by the day of the month as a decimal number (01-31).
 .TP
@@ -91,18 +94,33 @@ is replaced by the hour (12-hour clock) as a decimal number (01-12).
 .B %j
 is replaced by the day of the year as a decimal number (001-366).
 .TP
 .B %j
 is replaced by the day of the year as a decimal number (001-366).
 .TP
+.B %M
+is replaced by the minute as a decimal number (00-59).
+.TP
 .B %m
 is replaced by the month as a decimal number (01-12).
 .TP
 .B %m
 is replaced by the month as a decimal number (01-12).
 .TP
-.B %M
-is replaced by the minute as a decimal number (00-59).
+.B %n
+is replaced by a newline.
 .TP
 .B %p
 is replaced by either ``AM'' or ``PM'' as appropriate.
 .TP
 .TP
 .B %p
 is replaced by either ``AM'' or ``PM'' as appropriate.
 .TP
+.B %R
+is equivalent to ``%H:%M''.
+.TP
+.B %r
+is equivalent to ``%I:%M:%S %p''.
+.TP
+.B %t
+is replaced by a tab.
+.TP
 .B %S
 is replaced by the second as a decimal number (00-60).
 .TP
 .B %S
 is replaced by the second as a decimal number (00-60).
 .TP
+.B %T or %X
+is equivalent to ``%H:%M:%S''.
+.TP
 .B %U
 is replaced by the week number of the year (Sunday as the first day of
 the week) as a decimal number (00-53).
 .B %U
 is replaced by the week number of the year (Sunday as the first day of
 the week) as a decimal number (00-53).
@@ -115,9 +133,6 @@ the week) as a decimal number (00-53).
 is replaced by the weekday (Sunday as the first day of the week)
 as a decimal number (0-6).
 .TP
 is replaced by the weekday (Sunday as the first day of the week)
 as a decimal number (0-6).
 .TP
-.B %X
-is equivalent to ``%H:%M:%S''.
-.TP
 .B %x
 is equivalent to ``%a %b %d %Y''.
 .TP
 .B %x
 is equivalent to ``%a %b %d %Y''.
 .TP
index d4359f5..3dc2d90 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strftime.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)strftime.c 5.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -84,6 +84,7 @@ _fmt(format, t)
                                        return(0);
                                continue;
                        case 'b':
                                        return(0);
                                continue;
                        case 'b':
+                       case 'h':
                                if (!_add(bfmt[t->tm_mon]))
                                        return(0);
                                continue;
                                if (!_add(bfmt[t->tm_mon]))
                                        return(0);
                                continue;
@@ -91,6 +92,10 @@ _fmt(format, t)
                                if (!_fmt("%x %X %Z %Y", t))
                                        return(0);
                                continue;
                                if (!_fmt("%x %X %Z %Y", t))
                                        return(0);
                                continue;
+                       case 'D':
+                               if (!_fmt("%m/%d/%y", t))
+                                       return(0);
+                               continue;
                        case 'd':
                                if (!_conv(t->tm_mday, 2))
                                        return(0);
                        case 'd':
                                if (!_conv(t->tm_mday, 2))
                                        return(0);
@@ -115,14 +120,35 @@ _fmt(format, t)
                                if (!_conv(t->tm_mon + 1, 2))
                                        return(0);
                                continue;
                                if (!_conv(t->tm_mon + 1, 2))
                                        return(0);
                                continue;
+                       case 'n':
+                               if (!_add("\n"))
+                                       return(0);
+                               continue;
                        case 'p':
                                if (!_add(t->tm_hour >= 12 ? "AM" : "PM"))
                                        return(0);
                                continue;
                        case 'p':
                                if (!_add(t->tm_hour >= 12 ? "AM" : "PM"))
                                        return(0);
                                continue;
+                       case 'R':
+                               if (!_fmt("%H:%M", t))
+                                       return(0);
+                               continue;
+                       case 'r':
+                               if (!_fmt("%I:%M:%S %p", t))
+                                       return(0);
+                               continue;
                        case 'S':
                                if (!_conv(t->tm_sec, 2))
                                        return(0);
                                continue;
                        case 'S':
                                if (!_conv(t->tm_sec, 2))
                                        return(0);
                                continue;
+                       case 'T':
+                       case 'X':
+                               if (!_fmt("%H:%M:%S", t))
+                                       return(0);
+                               continue;
+                       case 't':
+                               if (!_add("\t"))
+                                       return(0);
+                               continue;
                        case 'U':
                                if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
                                    2))
                        case 'U':
                                if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
                                    2))
@@ -137,10 +163,6 @@ _fmt(format, t)
                                if (!_conv(t->tm_wday, 1))
                                        return(0);
                                continue;
                                if (!_conv(t->tm_wday, 1))
                                        return(0);
                                continue;
-                       case 'X':
-                               if (!_fmt("%H:%M:%S", t))
-                                       return(0);
-                               continue;
                        case 'x':
                                if (!_fmt("%a %b %d", t))
                                        return(0);
                        case 'x':
                                if (!_fmt("%a %b %d", t))
                                        return(0);