1996-01-04 12:36:39 -05:00
|
|
|
.\" Based on the UCB file whose copyright information appears below.
|
1996-01-04 12:16:13 -05:00
|
|
|
.\" Copyright (c) 1989, 1991 The Regents of the University of California.
|
|
|
|
|
.\" All rights reserved.
|
|
|
|
|
.\"
|
|
|
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
|
|
|
.\" the American National Standards Committee X3, on Information
|
|
|
|
|
.\" Processing Systems.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
|
.\" are met:
|
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
|
.\"
|
Don't abuse "`" to mean open quote.
This was appropriate before Unicode, where "`" and "'" often balanced
in visual output, but that's been obsolete for a while.
Overall, single-quote 'like this' instead of `like this', and
double-quote "like this" or (in typeset output) “like this”
instead of ``like this''. While we're at it, fix some glitches
with hyphens versus minus versus en dash versus em dash.
* Makefile ($(MANTXTS)): Use UTF-8 locale to produce *.txt output.
* checktab.awk, tzselect.ksh:
Quote 'like this' in diagnostics, instead of `like this'.
* date.1, newctime.3, newtzset.3, time2posix.3, zic.8 (q, lq, rq):
New macros. Use them for better double-quoting in output.
* workman.sh: Tell Perl that its stdin and stdout are UTF-8.
* NEWS: Document this.
2014-06-15 13:27:37 -07:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
|
1996-01-04 12:16:13 -05:00
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
|
.\"
|
|
|
|
|
.\" from: @(#)strftime.3 5.12 (Berkeley) 6/29/91
|
|
|
|
|
.\" $Id: strftime.3,v 1.4 1993/12/15 20:33:00 jtc Exp $
|
|
|
|
|
.\"
|
1996-01-04 12:39:23 -05:00
|
|
|
.TH NEWSTRFTIME 3
|
1996-01-04 12:36:39 -05:00
|
|
|
.SH NAME
|
|
|
|
|
strftime \- format date and time
|
|
|
|
|
.SH SYNOPSIS
|
|
|
|
|
.nf
|
2014-06-28 16:35:14 -07:00
|
|
|
.ie \n(.g .ds - \f(CW-\fP
|
|
|
|
|
.el ds - \-
|
1996-01-04 12:36:39 -05:00
|
|
|
.B #include <time.h>
|
|
|
|
|
.PP
|
2014-08-22 17:44:10 -07:00
|
|
|
.B "size_t strftime(char *restrict buf, size_t maxsize,"
|
|
|
|
|
.B " char const *restrict format, struct tm const *restrict timeptr);"
|
1996-01-04 12:36:39 -05:00
|
|
|
.PP
|
2014-06-17 18:46:31 -07:00
|
|
|
.B cc ... \-ltz
|
1996-01-04 12:36:39 -05:00
|
|
|
.fi
|
|
|
|
|
.SH DESCRIPTION
|
2014-06-17 18:46:31 -07:00
|
|
|
.ie '\(en'' .ds en \-
|
|
|
|
|
.el .ds en \(en
|
1996-01-04 12:16:13 -05:00
|
|
|
The
|
2014-06-28 16:35:14 -07:00
|
|
|
.I strftime
|
1996-01-04 12:16:13 -05:00
|
|
|
function formats the information from
|
2014-06-28 16:35:14 -07:00
|
|
|
.I timeptr
|
1996-01-04 12:16:13 -05:00
|
|
|
into the buffer
|
2014-06-28 16:35:14 -07:00
|
|
|
.I buf
|
1996-01-04 12:16:13 -05:00
|
|
|
according to the string pointed to by
|
2014-06-28 16:35:14 -07:00
|
|
|
.IR format .
|
1996-01-04 12:36:39 -05:00
|
|
|
.PP
|
1996-01-04 12:16:13 -05:00
|
|
|
The
|
2014-06-28 16:35:14 -07:00
|
|
|
.I format
|
1996-01-04 12:16:13 -05:00
|
|
|
string consists of zero or more conversion specifications and
|
|
|
|
|
ordinary characters.
|
|
|
|
|
All ordinary characters are copied directly into the buffer.
|
|
|
|
|
A conversion specification consists of a percent sign
|
|
|
|
|
.Ql %
|
|
|
|
|
and one other character.
|
1996-01-04 12:36:39 -05:00
|
|
|
.PP
|
1996-01-04 12:16:13 -05:00
|
|
|
No more than
|
2014-06-28 16:35:14 -07:00
|
|
|
.I maxsize
|
2014-06-17 06:09:24 +02:00
|
|
|
characters are placed into the array.
|
1996-01-04 12:16:13 -05:00
|
|
|
If the total number of resulting characters, including the terminating
|
|
|
|
|
null character, is not more than
|
2014-06-28 16:35:14 -07:00
|
|
|
.IR maxsize ,
|
|
|
|
|
.I strftime
|
1996-01-04 12:16:13 -05:00
|
|
|
returns the number of characters in the array, not counting the
|
|
|
|
|
terminating null.
|
|
|
|
|
Otherwise, zero is returned.
|
1996-01-04 12:36:39 -05:00
|
|
|
.PP
|
1996-01-04 12:16:13 -05:00
|
|
|
Each conversion specification is replaced by the characters as
|
|
|
|
|
follows which are then copied into the buffer.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%A
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the locale's full weekday name.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%a
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the locale's abbreviated weekday name.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%B
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the locale's full month name.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%b or %h
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the locale's abbreviated month name.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%C
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the century (a year divided by 100 and truncated to an integer)
|
2014-06-17 18:46:31 -07:00
|
|
|
as a decimal number (00\*(en99).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%c
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the locale's appropriate date and time representation.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%D
|
|
|
|
|
is replaced by the date in the format %m/%d/%y.
|
|
|
|
|
.TP
|
|
|
|
|
%d
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the day of the month as a decimal number (01\*(en31).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
1996-01-04 12:45:13 -05:00
|
|
|
%e
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the day of month as a decimal number (1\*(en31);
|
1996-01-04 12:45:13 -05:00
|
|
|
single digits are preceded by a blank.
|
|
|
|
|
.TP
|
2000-04-17 10:02:13 -04:00
|
|
|
%F
|
2014-06-28 16:35:14 -07:00
|
|
|
is replaced by the date in the format %Y\*-%m\*-%d.
|
2000-04-17 10:02:13 -04:00
|
|
|
.TP
|
1996-01-04 12:42:11 -05:00
|
|
|
%G
|
|
|
|
|
is replaced by the ISO 8601 year with century as a decimal number.
|
|
|
|
|
.TP
|
|
|
|
|
%g
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the ISO 8601 year without century as a decimal number (00\*(en99).
|
1996-01-04 12:42:11 -05:00
|
|
|
.TP
|
1996-01-04 12:36:39 -05:00
|
|
|
%H
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the hour (24-hour clock) as a decimal number (00\*(en23).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%I
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the hour (12-hour clock) as a decimal number (01\*(en12).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%j
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the day of the year as a decimal number (001\*(en366).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%k
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the hour (24-hour clock) as a decimal number (0\*(en23);
|
1996-01-04 12:16:13 -05:00
|
|
|
single digits are preceded by a blank.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%l
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the hour (12-hour clock) as a decimal number (1\*(en12);
|
1996-01-04 12:16:13 -05:00
|
|
|
single digits are preceded by a blank.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%M
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the minute as a decimal number (00\*(en59).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%m
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the month as a decimal number (01\*(en12).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%n
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by a newline.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%p
|
2005-01-31 14:06:05 -05:00
|
|
|
is replaced by the locale's equivalent of either AM or PM.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%R
|
|
|
|
|
is replaced by the time in the format %H:%M.
|
|
|
|
|
.TP
|
|
|
|
|
%r
|
2005-01-31 14:06:05 -05:00
|
|
|
is replaced by the locale's representation of 12-hour clock time
|
1996-01-04 12:16:13 -05:00
|
|
|
using AM/PM notation.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%S
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the second as a decimal number (00\*(en60).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%s
|
2013-09-05 06:53:45 -07:00
|
|
|
is replaced by the number of seconds since the Epoch (see newctime(3)).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
1996-01-04 12:47:12 -05:00
|
|
|
%T
|
|
|
|
|
is replaced by the time in the format %H:%M:%S.
|
|
|
|
|
.TP
|
|
|
|
|
%t
|
|
|
|
|
is replaced by a tab.
|
|
|
|
|
.TP
|
1996-01-04 12:36:39 -05:00
|
|
|
%U
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the week number of the year (Sunday as the first day of
|
2014-06-17 18:46:31 -07:00
|
|
|
the week) as a decimal number (00\*(en53).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%u
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the weekday (Monday as the first day of the week)
|
2014-06-17 18:46:31 -07:00
|
|
|
as a decimal number (1\*(en7).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%V
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the week number of the year (Monday as the first day of
|
2014-06-17 18:46:31 -07:00
|
|
|
the week) as a decimal number (01\*(en53). If the week containing January
|
1996-01-04 12:16:13 -05:00
|
|
|
1 has four or more days in the new year, then it is week 1; otherwise
|
|
|
|
|
it is week 53 of the previous year, and the next week is week 1.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%W
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the week number of the year (Monday as the first day of
|
2014-06-17 18:46:31 -07:00
|
|
|
the week) as a decimal number (00\*(en53).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%w
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the weekday (Sunday as the first day of the week)
|
2014-06-17 18:46:31 -07:00
|
|
|
as a decimal number (0\*(en6).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%X
|
1996-02-29 10:21:54 -05:00
|
|
|
is replaced by the locale's appropriate time representation.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%x
|
1996-02-29 10:21:54 -05:00
|
|
|
is replaced by the locale's appropriate date representation.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%Y
|
1996-01-04 12:16:13 -05:00
|
|
|
is replaced by the year with century as a decimal number.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%y
|
2014-06-17 18:46:31 -07:00
|
|
|
is replaced by the year without century as a decimal number (00\*(en99).
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%Z
|
2000-04-20 15:39:57 -04:00
|
|
|
is replaced by the time zone name,
|
|
|
|
|
or by the empty string if this is not determinable.
|
|
|
|
|
.TP
|
|
|
|
|
%z
|
2013-09-05 06:53:45 -07:00
|
|
|
is replaced by the offset from the Prime Meridian
|
2014-06-28 16:35:14 -07:00
|
|
|
in the format +HHMM or \*-HHMM as appropriate,
|
2000-04-20 15:39:57 -04:00
|
|
|
with positive values representing locations east of Greenwich,
|
|
|
|
|
or by the empty string if this is not determinable.
|
1996-01-04 12:36:39 -05:00
|
|
|
.TP
|
|
|
|
|
%%
|
|
|
|
|
is replaced by a single %.
|
1996-01-04 13:01:41 -05:00
|
|
|
.TP
|
|
|
|
|
%+
|
|
|
|
|
is replaced by the date and time in date(1) format.
|
1996-01-04 12:39:23 -05:00
|
|
|
.SH SEE ALSO
|
1996-01-04 13:01:41 -05:00
|
|
|
date(1),
|
1996-01-04 12:39:23 -05:00
|
|
|
getenv(3),
|
|
|
|
|
newctime(3),
|
|
|
|
|
newtzset(3),
|
|
|
|
|
time(2),
|
|
|
|
|
tzfile(5)
|