Skip to content

Commit

Permalink
Merge pull request #333 from oduwsdl/issue-332
Browse files Browse the repository at this point in the history
Windows locale detection for win32
  • Loading branch information
machawk1 authored Dec 14, 2017
2 parents 30ddaca + 048548b commit a37932f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ipwb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import locale
import datetime
import logging
import platform

import urllib2
import json
Expand Down Expand Up @@ -136,10 +137,15 @@ def retrieveMemCount():


def datetimeToRFC1123(digits14):
try:
locale.setlocale(locale.LC_TIME, 'en_US')
except locale.Error as e:
locale.setlocale(locale.LC_TIME, 'en_US.utf8')
currentOS = platform.system()
if currentOS == 'Darwin':
newLocale = 'en_US'
elif currentOS == 'Windows':
newLocale = 'english'
else: # Assume Linux
newLocale = 'en_US.utf8'

locale.setlocale(locale.LC_TIME, newLocale)
d = datetime.datetime.strptime(digits14, '%Y%m%d%H%M%S')
return d.strftime('%a, %d %b %Y %H:%M:%S GMT')

Expand Down

0 comments on commit a37932f

Please sign in to comment.