Remove locale.nl_langinfo as it doesn't work well on win32
and use LocalTime instead
This commit is contained in:
1 parent
0d4ad5164d
commit
ed34ff9fd8
5 files changed
+24
-43
No files matched your search
@@ -7,15 +7,10 @@ import locale
|
||||
from interface import WidgetInterface
|
||||
import tryton.rpc as rpc
|
||||
from tryton.common import DT_FORMAT, DHM_FORMAT, HM_FORMAT, message, TRYTON_ICON
|
||||
from _strptime import LocaleTime
|
||||
|
||||
_ = gettext.gettext
|
||||
|
||||
if not hasattr(locale, 'nl_langinfo'):
|
||||
locale.nl_langinfo = lambda *a: '%x'
|
||||
|
||||
if not hasattr(locale, 'D_FMT'):
|
||||
locale.D_FMT = None
|
||||
|
||||
|
||||
class Calendar(WidgetInterface):
|
||||
"Calendar"
|
||||
@@ -71,8 +66,8 @@ class Calendar(WidgetInterface):
|
||||
if value == '':
|
||||
return False
|
||||
try:
|
||||
date = time.strptime(value, locale.nl_langinfo(
|
||||
locale.D_FMT).replace('%y', '%Y'))
|
||||
date = time.strptime(value,
|
||||
LocaleTime().LC_date.replace('%y', '%Y'))
|
||||
except:
|
||||
return False
|
||||
return time.strftime(DT_FORMAT, date)
|
||||
@@ -93,8 +88,8 @@ class Calendar(WidgetInterface):
|
||||
if len(value)>10:
|
||||
value = value[:10]
|
||||
date = time.strptime(value, DT_FORMAT)
|
||||
value = time.strftime(locale.nl_langinfo(
|
||||
locale.D_FMT).replace('%y', '%Y'), date)
|
||||
value = time.strftime(LocaleTime().LC_date.replace('%y', '%Y'),
|
||||
date)
|
||||
if len(value) > self.entry.get_width_chars():
|
||||
self.entry.set_width_chars(len(value))
|
||||
self.entry.set_text(value)
|
||||
@@ -134,7 +129,7 @@ class Calendar(WidgetInterface):
|
||||
year, month, day = cal.get_date()
|
||||
date = DT.date(year, month+1, day)
|
||||
self.entry.set_text(date.strftime(
|
||||
locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')))
|
||||
LocaleTime().LC_date.replace('%y', '%Y')))
|
||||
self._focus_out()
|
||||
self._window.present()
|
||||
win.destroy()
|
||||
@@ -192,8 +187,8 @@ class DateTime(WidgetInterface):
|
||||
if value == '':
|
||||
return False
|
||||
try:
|
||||
date = time.strptime(value, locale.nl_langinfo(
|
||||
locale.D_FMT).replace('%y', '%Y') + ' ' + HM_FORMAT)
|
||||
date = time.strptime(value,
|
||||
LocaleTime().LC_date.replace('%y', '%Y') + ' ' + HM_FORMAT)
|
||||
except:
|
||||
return False
|
||||
if 'timezone' in rpc.CONTEXT and timezone:
|
||||
@@ -237,8 +232,9 @@ class DateTime(WidgetInterface):
|
||||
date = ldt.timetuple()
|
||||
except:
|
||||
pass
|
||||
value = time.strftime(locale.nl_langinfo(
|
||||
locale.D_FMT).replace('%y', '%Y') + ' ' + HM_FORMAT, date)
|
||||
value = time.strftime(
|
||||
LocaleTime().LC_date.replace('%y', '%Y') + ' ' + HM_FORMAT,
|
||||
date)
|
||||
if len(value) > self.entry.get_width_chars():
|
||||
self.entry.set_width_chars(len(value))
|
||||
self.entry.set_text(value)
|
||||
|
||||
@@ -9,6 +9,7 @@ import time
|
||||
import tryton.rpc as rpc
|
||||
import cairo
|
||||
from tryton.action import Action
|
||||
from _strptime import LocaleTime
|
||||
|
||||
|
||||
class Popup(object):
|
||||
@@ -360,8 +361,8 @@ class Graph(gtk.DrawingArea):
|
||||
end_date = mx.DateTime.mktime(time.strptime(str(maxx), '%Y-%m-%d'))
|
||||
while date <= end_date:
|
||||
key = datetime.date(date.year, date.month, date.day)
|
||||
self.labels[key] = time.strftime(locale.nl_langinfo(
|
||||
locale.D_FMT).replace('%y', '%Y'),
|
||||
self.labels[key] = time.strftime(
|
||||
LocaleTime().LC_date.replace('%y', '%Y'),
|
||||
time.strptime(str(key), DT_FORMAT))
|
||||
self.datas.setdefault(key, {})
|
||||
for yfield in self.yfields:
|
||||
|
||||
@@ -19,12 +19,7 @@ import tryton.rpc as rpc
|
||||
import datetime as DT
|
||||
from tryton.common import DT_FORMAT, DHM_FORMAT, COLORS, node_attributes, TRYTON_ICON
|
||||
import tryton.common as common
|
||||
|
||||
if not hasattr(locale, 'nl_langinfo'):
|
||||
locale.nl_langinfo = lambda *a: '%x'
|
||||
|
||||
if not hasattr(locale, 'D_FMT'):
|
||||
locale.D_FMT = None
|
||||
from _strptime import LocaleTime
|
||||
|
||||
def send_keys(renderer, editable, position, treeview):
|
||||
editable.connect('key_press_event', treeview.on_keypressed)
|
||||
@@ -276,7 +271,7 @@ class Boolean(Int):
|
||||
|
||||
class Date(Char):
|
||||
server_format = DT_FORMAT
|
||||
display_format = locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')
|
||||
display_format = LocaleTime().LC_date.replace('%y', '%Y')
|
||||
|
||||
def get_textual_value(self, model):
|
||||
value = model[self.field_name].get_client(model)
|
||||
@@ -302,7 +297,7 @@ class Date(Char):
|
||||
|
||||
class Datetime(Date):
|
||||
server_format = DHM_FORMAT
|
||||
display_format = locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y') + \
|
||||
display_format = LocaleTime().LC_date.replace('%y', '%Y') + \
|
||||
' %H:%M:%S'
|
||||
|
||||
def get_textual_value(self, model):
|
||||
|
||||
@@ -6,15 +6,10 @@ import gettext
|
||||
import locale
|
||||
from interface import Interface
|
||||
from tryton.common import DT_FORMAT
|
||||
from _strptime import LocaleTime
|
||||
|
||||
_ = gettext.gettext
|
||||
|
||||
if not hasattr(locale, 'nl_langinfo'):
|
||||
locale.nl_langinfo = lambda *a: '%x'
|
||||
|
||||
if not hasattr(locale, 'D_FMT'):
|
||||
locale.D_FMT = None
|
||||
|
||||
|
||||
class Calendar(Interface):
|
||||
|
||||
@@ -65,7 +60,7 @@ class Calendar(Interface):
|
||||
def _date_get(self, value):
|
||||
try:
|
||||
date = time.strptime(value,
|
||||
locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y'))
|
||||
LocaleTime().LC_date.replace('%y', '%Y'))
|
||||
except:
|
||||
return False
|
||||
return time.strftime(DT_FORMAT, date)
|
||||
@@ -115,7 +110,7 @@ class Calendar(Interface):
|
||||
year, month, day = cal.get_date()
|
||||
date = DT.date(year, month+1, day)
|
||||
dest.set_text(date.strftime(
|
||||
locale.nl_langinfo(locale.D_FMT).replace('%y', '%Y')))
|
||||
LocaleTime().LC_date.replace('%y', '%Y')))
|
||||
win.destroy()
|
||||
|
||||
def clear(self):
|
||||
|
||||
@@ -11,12 +11,7 @@ import datetime as DT
|
||||
import locale
|
||||
from tryton.common import DT_FORMAT, DHM_FORMAT
|
||||
import tryton.common as common
|
||||
|
||||
if not hasattr(locale, 'nl_langinfo'):
|
||||
locale.nl_langinfo = lambda *a: '%x'
|
||||
|
||||
if not hasattr(locale, 'D_FMT'):
|
||||
locale.D_FMT = None
|
||||
from _strptime import LocaleTime
|
||||
|
||||
FIELDS_LIST_TYPE = {
|
||||
'boolean': gobject.TYPE_BOOLEAN,
|
||||
@@ -78,15 +73,14 @@ class ViewTreeModel(gtk.GenericTreeModel, gtk.TreeSortable):
|
||||
and 'widget' in self.fields_attrs[field]:
|
||||
field_type = self.fields_attrs[field]['widget']
|
||||
if field_type in ('date',):
|
||||
display_format = locale.nl_langinfo(locale.D_FMT).replace('%y',
|
||||
'%Y')
|
||||
display_format = LocaleTime().LC_date.replace('%y', '%Y')
|
||||
for obj in res_ids:
|
||||
if obj[field]:
|
||||
date = time.strptime(obj[field], DT_FORMAT)
|
||||
obj[field] = time.strftime(display_format, date)
|
||||
elif field_type in ('datetime',):
|
||||
display_format = locale.nl_langinfo(locale.D_FMT).replace('%y',
|
||||
'%Y') + ' %H:%M:%S'
|
||||
display_format = LocaleTime().LC_date.replace('%y', '%Y') \
|
||||
+ ' %H:%M:%S'
|
||||
for obj in res_ids:
|
||||
if obj[field]:
|
||||
date = time.strptime(obj[field], DHM_FORMAT)
|
||||
|
||||
Reference in new issue
Block a user