<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: ctime code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 04:20:42 GMT</pubDate>
    <description>DZone Snippets: ctime code</description>
    <item>
      <title>Change system date of photos to EXIF date</title>
      <link>http://snippets.dzone.com/posts/show/4089</link>
      <description>This script takes a list of files as arguments.&lt;br /&gt;It set the system datetime (both modifitation and access) to the date &lt;br /&gt;the photo was taken.&lt;br /&gt;&lt;br /&gt;It use the EXIF module for that, that needs to be in the same folder as the script :&lt;br /&gt;You can find it here :&lt;br /&gt;http://home.cfl.rr.com/genecash/digital_camera/EXIF.py &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/python&lt;br /&gt;&lt;br /&gt;import sys&lt;br /&gt;import EXIF&lt;br /&gt;from datetime import *&lt;br /&gt;import time&lt;br /&gt;import os&lt;br /&gt;&lt;br /&gt;# Loop on arguments (files)&lt;br /&gt;for arg in sys.argv[1:] :&lt;br /&gt;    &lt;br /&gt;    # Do nothing of dirs&lt;br /&gt;    if os.path.isdir(arg) :&lt;br /&gt;        continue&lt;br /&gt;&lt;br /&gt;    # Open the file&lt;br /&gt;    f=open(arg, 'rb')&lt;br /&gt; &lt;br /&gt;    # Read exif data&lt;br /&gt;    tags = EXIF.process_file(f)&lt;br /&gt;    &lt;br /&gt;    # Ensure date is present &lt;br /&gt;    if not tags.has_key("Image DateTime") :&lt;br /&gt;        continue &lt;br /&gt;        &lt;br /&gt;    # Get date of photo&lt;br /&gt;    date = tags["Image DateTime"]&lt;br /&gt;    date = datetime(*(time.strptime(date.values, "%Y:%m:%d %H:%M:%S")[0:6]))&lt;br /&gt;    timestamp = int(time.mktime(date.timetuple()))&lt;br /&gt;    &lt;br /&gt;    # Some traces&lt;br /&gt;    print "File:%s - Time:%s " % (arg, timestamp)&lt;br /&gt;&lt;br /&gt;    # Change the date&lt;br /&gt;    os.utime(arg, (timestamp, timestamp))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 02 Jun 2007 00:10:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4089</guid>
      <author>cdvddt (Raphael Jolivet)</author>
    </item>
    <item>
      <title>PyS60 - listSMS to File.txt</title>
      <link>http://snippets.dzone.com/posts/show/3042</link>
      <description>// Salva la lista degli SMS in un file&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from time import ctime&lt;br /&gt;&lt;br /&gt;import codecs&lt;br /&gt;import inbox&lt;br /&gt;&lt;br /&gt;box = inbox.Inbox()&lt;br /&gt;msg = box.sms_messages()&lt;br /&gt;&lt;br /&gt;f = codecs.open('E:/Others/listSMS.txt', 'w', 'utf8') # Apre il file in codifica UTF8&lt;br /&gt;for i in msg:&lt;br /&gt;	f.write(box.address(i))&lt;br /&gt;	f.write('\n')&lt;br /&gt;	f.write(ctime(box.time(i))) # Converte i secondi in una stringa rappresentante il tempo&lt;br /&gt;	f.write('\n')&lt;br /&gt;	f.write(box.content(i))&lt;br /&gt;	f.write('\n')&lt;br /&gt;f.close()&lt;br /&gt;&lt;br /&gt;print 'Fine'&lt;br /&gt;&lt;br /&gt;f = codecs.open('E:/Others/listSMS.txt', 'r', 'utf8')&lt;br /&gt;print f.read()&lt;br /&gt;f.close()&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 27 Nov 2006 00:52:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3042</guid>
      <author>whitetiger ()</author>
    </item>
  </channel>
</rss>
