Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with timezone with time.strftime
    text
    copied!<p>I've been using <a href="http://www.aczoom.com/blockhosts" rel="nofollow">blockhosts</a> for some time now, and it's been great so far. I recently updated Ubuntu to 10.10, and I started to see some erratic behaviour. Upon a closer inspection, I noticed a bunch of errors in /var/log/blockhosts.log:</p> <p><code>ERROR: failed to parse date for ip 188.17.155.25, using now value: time data '2010-11-01 03:04:02 AMT' does not match format '%Y-%m-%d %H:%M:%S %Z'</code></p> <p>The fact of the timezone appearing as "AMT" (Armenian time) is strange. My timezone is set as:</p> <p><code>$ cat /etc/timezone<br> Europe/Amsterdam</code></p> <p>I took a look at the code of <code>blockhosts.py</code> where the date is handled and checked, and I saw that is being handled as <code>time</code> objects.</p> <p>The following code shows the problem:</p> <pre><code>import time now = time.time() str1 = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime()) str2 = time.strftime('%Y-%m-%d %H:%M:%S %Z') print str1 print str2 </code></pre> <p>The output is the following:</p> <pre><code>2010-12-06 16:18:47 AMT 2010-12-06 16:18:47 CET </code></pre> <p>The value of <code>time.tzname</code> is <code>('CET', 'CEST')</code>, so I'm not sure where the "AMT" is coming from... </p> <p>Any help will be appreciated!</p> <p><strong>Updates:</strong></p> <p>From the suggestions in the comments:</p> <ul> <li><code>/etc/localtime</code> is not a symlink to <code>/usr/share/zoneinfo/Europe/Amsterdam</code>, but they are the same file:</li> </ul> <p><code>$ ls -l /etc/localtime<br> -rw-r--r-- 1 root root 2917 2010-11-18 09:35 /etc/localtime<br> $ ls -l /usr/share/zoneinfo/Europe/Amsterdam<br> -rw-r--r-- 1 root root 2917 2010-11-11 09:35 /usr/share/zoneinfo/Europe/Amsterdam<br> $ diff /etc/localtime /usr/share/zoneinfo/Europe/Amsterdam</code></p> <ul> <li>there is no TZ environment variable:</li> </ul> <p><code>$ echo $TZ<br> $ env | grep TZ</code></p> <ul> <li>I logged in as another user and run the script with the same result:</li> </ul> <p><code>2010-12-07 11:12:09 AMT<br> 2010-12-07 11:12:09 CET</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload