Skip to content

Commit

Permalink
Fixed non-UTC timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
cemsbr committed May 14, 2015
1 parent 039fbb1 commit 908f83f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/test_wiki2json.py
Expand Up @@ -178,7 +178,7 @@ def test_timestamp_conversion(self):
<page>
<timestamp>2015-03-04T13:45:11Z</timestamp>
</page>""")
expected = '{"timestamp":1425444311}'
expected = '{"timestamp":1425476711}'
self.assertEqual(expected, actual)

def test_numeric_tags(self):
Expand Down
5 changes: 4 additions & 1 deletion wiki2json/wiki2json.py
Expand Up @@ -3,6 +3,7 @@
import builtins
from io import StringIO
from datetime import datetime
import time


# Do not print extra newline
Expand Down Expand Up @@ -31,7 +32,9 @@ def append_multiline_text(self, text):
self._text.write(text)

def add_timestamp(self, iso):
print(int(datetime.strptime(iso, '%Y-%m-%dT%H:%M:%SZ').timestamp()))
local = datetime.strptime(iso, '%Y-%m-%dT%H:%M:%SZ').timestamp()
utc = local - time.timezone
print(int(utc))

# Adds previously appended text
def _finish_multiline_text(self):
Expand Down

0 comments on commit 908f83f

Please sign in to comment.