<li><strong>Module 'datetime' provides 'date' <codeclass="python hljs"><D></code>, 'time' <codeclass="python hljs"><T></code>, 'datetime' <codeclass="python hljs"><DT></code> and 'timedelta' <codeclass="python hljs"><TD></code> classes. All are immutable and hashable.</strong></li>
<li><strong>Time and datetime can be 'aware' <codeclass="python hljs"><a></code>, meaning they have defined timezone, or 'naive' <codeclass="python hljs"><n></code>, meaning they don't.</strong></li>
<li><strong>Module 'datetime' provides 'date' <codeclass="apache hljs"><spanclass="hljs-section"><D></span></code>, 'time' <codeclass="apache hljs"><spanclass="hljs-section"><T></span></code>, 'datetime' <codeclass="apache hljs"><spanclass="hljs-section"><DT></span></code> and 'timedelta' <codeclass="apache hljs"><spanclass="hljs-section"><TD></span></code> classes. All are immutable and hashable.</strong></li>
<li><strong>Time and datetime can be 'aware' <codeclass="apache hljs"><spanclass="hljs-section"><a></span></code>, meaning they have defined timezone, or 'naive' <codeclass="apache hljs"><spanclass="hljs-section"><n></span></code>, meaning they don't.</strong></li>
<li><strong>If object is naive it is presumed to be in system's timezone.</strong></li>
</ul>
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> datetime <spanclass="hljs-keyword">import</span> date, time, datetime, timedelta
<Ta/DTa> = <T/DT>.replace(tzinfo=<tz>) <spanclass="hljs-comment"># Unconverted object with new timezone.</span>
</code></pre>
<h3id="encode">Encode</h3>
<pre><codeclass="python language-python hljs"><D/T/DT> = D/T/DT.fromisoformat(<spanclass="hljs-string">'<iso>'</span>) <spanclass="hljs-comment"># Object from ISO string.</span>
<pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<spanclass="hljs-string">'<iso>'</span>) <spanclass="hljs-comment"># Object from ISO string.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DTn from days since Christ.</span>
<DTa> = DT.fromtimestamp(<real>, <tz>) <spanclass="hljs-comment"># DTa from seconds since Epoch in tz time.</span>
@ -502,7 +502,7 @@ shuffle(<list>)
<li><strong>On Unix systems Epoch is <codeclass="python hljs"><spanclass="hljs-string">'1970-01-01 00:00 UTC'</span></code>, <codeclass="python hljs"><spanclass="hljs-string">'1970-01-01 01:00 CET'</span></code>, …</strong></li>
</ul>
<h3id="decode">Decode</h3>
<pre><codeclass="python language-python hljs"><str> = <D/T/DT>.isoformat() <spanclass="hljs-comment"># ISO string representation.</span>
<pre><codeclass="python language-python apache hljs"><str> = <D/T/DT>.isoformat() <spanclass="hljs-comment"># ISO string representation.</span>