Popular recipes tagged "date" but not "jpg"http://code.activestate.com/recipes/tags/date-jpg/2015-03-14T01:25:49-07:00ActiveState Code Recipesstart and end date given the year and week (Python) 2015-03-14T01:25:49-07:00Fernando Peraltahttp://code.activestate.com/recipes/users/4191815/http://code.activestate.com/recipes/579034-start-and-end-date-given-the-year-and-week/ <p style="color: grey"> Python recipe 579034 by <a href="/recipes/users/4191815/">Fernando Peralta</a> (<a href="/recipes/tags/and/">and</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/end/">end</a>, <a href="/recipes/tags/given/">given</a>, <a href="/recipes/tags/start/">start</a>, <a href="/recipes/tags/week/">week</a>, <a href="/recipes/tags/year/">year</a>). </p> <p>Determines the starting and ending date when the year and week are specified for a by-weekly report.</p> Monday of first week per year (not first Monday) (Python) 2012-10-31T04:37:28-07:00Scott S-Allenhttp://code.activestate.com/recipes/users/4181178/http://code.activestate.com/recipes/578308-monday-of-first-week-per-year-not-first-monday/ <p style="color: grey"> Python recipe 578308 by <a href="/recipes/users/4181178/">Scott S-Allen</a> (<a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/week/">week</a>). Revision 4. </p> <p>13th week of any year is ambiguous without identifying the first week. </p> <p>This recipe calculates Monday of the first week, not the first Monday, and differs from others by not using flow-control statement (if).</p> Human readable format for a given time delta (Python) 2012-04-26T10:37:10-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578113-human-readable-format-for-a-given-time-delta/ <p style="color: grey"> Python recipe 578113 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/back/">back</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/human/">human</a>, <a href="/recipes/tags/readable/">readable</a>, <a href="/recipes/tags/time/">time</a>). </p> <p><strong>What is it about?</strong></p> <ul> <li>I need to say someting like <em>1 day ago</em>, <em>5 days ago</em>, <em>2 weeks ago</em>, ...</li> <li>I can control to have it with/without milliseconds and microseconds.</li> <li>I can use it automatically with current date and time or with a provide one.</li> </ul> <p><strong>Why?</strong></p> <ul> <li>I need it for next revision of my <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a>.</li> <li>I found recipes here and there but often it is always assumed that a month has 30 days and that a year has 365 days; this is not true. That's why I've left away months and years.</li> </ul> subtract 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> make some file named year+month+day (Python) 2012-02-10T23:46:36-08:00ryotaro gotohttp://code.activestate.com/recipes/users/4180840/http://code.activestate.com/recipes/578036-make-some-file-named-yearmonthday/ <p style="color: grey"> Python recipe 578036 by <a href="/recipes/users/4180840/">ryotaro goto</a> (<a href="/recipes/tags/beginner/">beginner</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/sys/">sys</a>). Revision 6. </p> <p>This program make some file named year+month+day How to use "python program argument example:argument=01,02,...,12 If you input 02,it will return files named 20120201,...,20120228</p> Cheap-date trick; a different way to parse (Python) 2012-03-06T14:08:10-08:00Scott S-Allenhttp://code.activestate.com/recipes/users/4181178/http://code.activestate.com/recipes/578064-cheap-date-trick-a-different-way-to-parse/ <p style="color: grey"> Python recipe 578064 by <a href="/recipes/users/4181178/">Scott S-Allen</a> (<a href="/recipes/tags/cheap/">cheap</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/parse/">parse</a>, <a href="/recipes/tags/regex/">regex</a>, <a href="/recipes/tags/sharp/">sharp</a>). </p> <p>... a light meal with a heavy dose of "tutorial mash" on the side.</p> <p>In the constructive spirit of "more ways to solve a problem"; this is a portion of my lateral, occasionally oblique, solutions. Nothing new in le régime de grande, but hopefully the conceptual essence will amuse.</p> <p>Initially started as a response to <a href="http://code.activestate.com/recipes/577135/">recipe 577135</a> which parses incremental date fragments and preserves micro-seconds where available. That script does more work than this, for sure, but requires special flow-control and iterates a potentially incumbering shopping list (multi-dimensional with some detail).</p> <p>So here's a different box for others to play with. Upside-down in a sense, it doesn't hunt for anything but a numerical "pulse"; sequences of digits punctuated by other 'stuff' we don't much care about.</p> <p>Missing a lot of things, intentionally, this snippet provides several examples demoin' flexibility. Easy to button-up, redecorate and extend later for show, till then the delightful commentary makes it hard enough to see bones already -- all six lines or so!</p> <p><strong>Note:</strong> <em>The core script is repeated for illustrative purposes. The first is step-by-step, the second is lean and condensed for utilitarian purposes. It is the second, shorter, version that I yanked from a file and gussied up.</em></p> 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>&gt;&gt;&gt; import datetime &gt;&gt;&gt; str(datetime.datetime.now()) '2010-03-21 21:33:32.750246' &gt;&gt;&gt; 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> Redate pictures with EXIF (Python) 2009-06-29T03:06:01-07:00Ivan Koblikhttp://code.activestate.com/recipes/users/4168407/http://code.activestate.com/recipes/576822-redate-pictures-with-exif/ <p style="color: grey"> Python recipe 576822 by <a href="/recipes/users/4168407/">Ivan Koblik</a> (<a href="/recipes/tags/creation_date/">creation_date</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/modification_date/">modification_date</a>, <a href="/recipes/tags/picture/">picture</a>, <a href="/recipes/tags/video/">video</a>). Revision 2. </p> <p>Reads creation date from EXIF picture/video file header, and sets it to the file's creation and modification dates. This script differs from other recipes in its ability to work with the creation date in Windows. The script depends on several libraries: Win32 Extensions, pyexif, exif. <a href="http://koblik.blogspot.com/2009/06/exif-with-python.html">Here's</a> description of what they do and where to get them.</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>