Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / node257.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="datetime-tzinfo.html" />
13<link rel="parent" href="module-datetime.html" />
14<link rel="next" href="module-time.html" />
15<meta name='aesop' content='information' />
16<title>6.10.7 strftime() Behavior</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="6.10.6 tzinfo Objects"
24 href="datetime-tzinfo.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="6.10 datetime "
27 href="module-datetime.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="6.11 time "
30 href="module-time.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="datetime-tzinfo.html">6.10.6 tzinfo Objects</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module-datetime.html">6.10 datetime </A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-time.html">6.11 time </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION0081070000000000000000">
556.10.7 <tt class="method">strftime()</tt> Behavior</A>
56</H2>
57
58<P>
59<tt class="class">date</tt>, <tt class="class">datetime</tt>, and <tt class="class">time</tt>
60objects all support a <code>strftime(<var>format</var>)</code>
61method, to create a string representing the time under the control of
62an explicit format string. Broadly speaking,
63<code>d.strftime(fmt)</code>
64acts like the <tt class="module"><a href="module-time.html">time</a></tt> module's
65<code>time.strftime(fmt, d.timetuple())</code>
66although not all objects support a <tt class="method">timetuple()</tt> method.
67
68<P>
69For <tt class="class">time</tt> objects, the format codes for
70year, month, and day should not be used, as time objects have no such
71values. If they're used anyway, <code>1900</code> is substituted for the
72year, and <code>0</code> for the month and day.
73
74<P>
75For <tt class="class">date</tt> objects, the format codes for hours, minutes, and
76seconds should not be used, as <tt class="class">date</tt> objects have no such
77values. If they're used anyway, <code>0</code> is substituted for them.
78
79<P>
80For a naive object, the <code>%z</code> and <code>%Z</code> format codes are
81replaced by empty strings.
82
83<P>
84For an aware object:
85
86<P>
87<DL COMPACT>
88<DT><code>%z</code></DT>
89<DD><tt class="method">utcoffset()</tt> is transformed into a 5-character string of
90 the form +HHMM or -HHMM, where HH is a 2-digit string giving the
91 number of UTC offset hours, and MM is a 2-digit string giving the
92 number of UTC offset minutes. For example, if
93 <tt class="method">utcoffset()</tt> returns <code>timedelta(hours=-3, minutes=-30)</code>,
94 <code>%z</code> is replaced with the string <code>'-0330'</code>.
95
96<P>
97</DD>
98<DT><code>%Z</code></DT>
99<DD>If <tt class="method">tzname()</tt> returns <code>None</code>, <code>%Z</code> is replaced
100 by an empty string. Otherwise <code>%Z</code> is replaced by the returned
101 value, which must be a string.
102</DD>
103</DL>
104
105<P>
106The full set of format codes supported varies across platforms,
107because Python calls the platform C library's <tt class="function">strftime()</tt>
108function, and platform variations are common. The documentation for
109Python's <tt class="module"><a href="module-time.html">time</a></tt> module lists the format codes that the C
110standard (1989 version) requires, and those work on all platforms
111with a standard C implementation. Note that the 1999 version of the
112C standard added additional format codes.
113
114<P>
115The exact range of years for which <tt class="method">strftime()</tt> works also
116varies across platforms. Regardless of platform, years before 1900
117cannot be used.
118
119<DIV CLASS="navigation">
120<div class='online-navigation'>
121<p></p><hr />
122<table align="center" width="100%" cellpadding="0" cellspacing="2">
123<tr>
124<td class='online-navigation'><a rel="prev" title="6.10.6 tzinfo Objects"
125 href="datetime-tzinfo.html"><img src='../icons/previous.png'
126 border='0' height='32' alt='Previous Page' width='32' /></A></td>
127<td class='online-navigation'><a rel="parent" title="6.10 datetime "
128 href="module-datetime.html"><img src='../icons/up.png'
129 border='0' height='32' alt='Up One Level' width='32' /></A></td>
130<td class='online-navigation'><a rel="next" title="6.11 time "
131 href="module-time.html"><img src='../icons/next.png'
132 border='0' height='32' alt='Next Page' width='32' /></A></td>
133<td align="center" width="100%">Python Library Reference</td>
134<td class='online-navigation'><a rel="contents" title="Table of Contents"
135 href="contents.html"><img src='../icons/contents.png'
136 border='0' height='32' alt='Contents' width='32' /></A></td>
137<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
138 border='0' height='32' alt='Module Index' width='32' /></a></td>
139<td class='online-navigation'><a rel="index" title="Index"
140 href="genindex.html"><img src='../icons/index.png'
141 border='0' height='32' alt='Index' width='32' /></A></td>
142</tr></table>
143<div class='online-navigation'>
144<b class="navlabel">Previous:</b>
145<a class="sectref" rel="prev" href="datetime-tzinfo.html">6.10.6 tzinfo Objects</A>
146<b class="navlabel">Up:</b>
147<a class="sectref" rel="parent" href="module-datetime.html">6.10 datetime </A>
148<b class="navlabel">Next:</b>
149<a class="sectref" rel="next" href="module-time.html">6.11 time </A>
150</div>
151</div>
152<hr />
153<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
154</DIV>
155<!--End of Navigation Panel-->
156<ADDRESS>
157See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
158</ADDRESS>
159</BODY>
160</HTML>