Coverage for adhoc-cicd-odoo-odoo / odoo / _monkeypatches / locale.py: 26%
25 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:15 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:15 +0000
1# Part of Odoo. See LICENSE file for full copyright and licensing details.
3import locale
4import time
5import datetime
8def patch_module():
9 if not hasattr(locale, 'D_FMT'): 9 ↛ 10line 9 didn't jump to line 10 because the condition on line 9 was never true
10 locale.D_FMT = 1
12 if not hasattr(locale, 'T_FMT'): 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true
13 locale.T_FMT = 2
15 if not hasattr(locale, 'nl_langinfo'): 15 ↛ 16line 15 didn't jump to line 16 because the condition on line 15 was never true
16 def nl_langinfo(param):
17 if param == locale.D_FMT:
18 val = time.strptime('30/12/2004', '%d/%m/%Y')
19 dt = datetime.datetime(*val[:-2])
20 format_date = dt.strftime('%x')
21 for x, y in [('30', '%d'), ('12', '%m'), ('2004', '%Y'), ('04', '%Y')]:
22 format_date = format_date.replace(x, y)
23 return format_date
24 if param == locale.T_FMT:
25 val = time.strptime('13:24:56', '%H:%M:%S')
26 dt = datetime.datetime(*val[:-2])
27 format_time = dt.strftime('%X')
28 for x, y in [('13', '%H'), ('24', '%M'), ('56', '%S')]:
29 format_time = format_time.replace(x, y)
30 return format_time
31 locale.nl_langinfo = nl_langinfo