Popular recipes tagged "datetime" and "date" but not "string"http://code.activestate.com/recipes/tags/datetime-string+date/2010-07-30T10:00:25-07:00ActiveState Code Recipessubtract or add a month to a datetime.date or datetime.datetime (Python)
2010-06-25T18:41:19-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577274-subtract-or-add-a-month-to-a-datetimedate-or-datet/
<p style="color: grey">
Python
recipe 577274
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/month/">month</a>).
</p>
<p>Adding or subtracting a month to a Python <code>datetime.date</code> or <code>datetime.datetime</code> is a little bit of a pain. Here is the code I use for that. These functions return the same datetime type as given. They preserve time of day data (if that is at all important to you).</p>
<p>See also: </p>
<ul>
<li><a href="http://code.activestate.com/recipes/476197/">Recipe 476197</a>: First / Last Day of the Month.</li>
<li><a href="http://packages.python.org/MonthDelta/">monthdelta module</a></li>
</ul>
Redate source files using SVN info from $Id:$ (Python)
2010-07-30T10:00:25-07:00Michal Niklashttp://code.activestate.com/recipes/users/186902/http://code.activestate.com/recipes/577341-redate-source-files-using-svn-info-from-id/
<p style="color: grey">
Python
recipe 577341
by <a href="/recipes/users/186902/">Michal Niklas</a>
(<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/svn/">svn</a>).
</p>
<p>Iterates through a directory, reading the data from svn info that looks like:</p>
<pre class="prettyprint"><code>$Id: svn_redater.py 747 2010-07-30 09:56:08Z mn $
</code></pre>
<p>from source files.</p>
<p>Parses the datetime from svn info and if it differs from file
modification datetime then changes file datetime</p>
parse a date/time string to a `datetime` instance (Python)
2010-04-02T07:32:17-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/577135-parse-a-datetime-string-to-a-datetime-instance/
<p style="color: grey">
Python
recipe 577135
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/time/">time</a>).
Revision 2.
</p>
<pre class="prettyprint"><code>>>> import datetime
>>> str(datetime.datetime.now())
'2010-03-21 21:33:32.750246'
>>> str(datetime.date.today())
'2010-03-21'
</code></pre>
<p>This function goes the other way for date and datetime strings of this format.</p>
Compare passed day of week to today's day of week (Python)
2009-01-17T20:51:26-08:00Samuel Huckinshttp://code.activestate.com/recipes/users/4168906/http://code.activestate.com/recipes/576619-compare-passed-day-of-week-to-todays-day-of-week/
<p style="color: grey">
Python
recipe 576619
by <a href="/recipes/users/4168906/">Samuel Huckins</a>
(<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/dayofweek/">dayofweek</a>).
</p>
<p>This function compares the day of the week of today to the day of the week passed.</p>