https://github.com/odoo/o-spreadsheet/commit/7d15d3c7 [REL] 16.4.0-alpha.6 https://github.com/odoo/o-spreadsheet/commit/56f3b593 [IMP] spreadsheet: add locale handling Task: 3222401 https://github.com/odoo/o-spreadsheet/commit/5aec70d4 [IMP] cell: store date string as value + format Task: 3222401 https://github.com/odoo/o-spreadsheet/commit/eeaf0083 [IMP] icons: add display header icon https://github.com/odoo/o-spreadsheet/commit/3f1e970c [FIX] SelectionInput: fix position of exclamation mark icon Task: 3355063 https://github.com/odoo/o-spreadsheet/commit/a46bf04e [FIX] LineBarPieConfigPanel: charts data series invalid input Task: 3355063 closes odoo/odoo#126679 Related: odoo/enterprise#43291 Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
import json
|
|
import base64
|
|
import re
|
|
|
|
from odoo import _
|
|
|
|
strftime_to_spreadsheet_time_format_table = {
|
|
"%H": "hh",
|
|
"%I": "hh",
|
|
"%M": "mm",
|
|
"%S": "ss",
|
|
}
|
|
|
|
strftime_to_spreadsheet_dateformat_table = {
|
|
"%Y": "yyyy",
|
|
"%y": "yy",
|
|
"%m": "mm",
|
|
"%b": "mmm",
|
|
"%B": "mmmm",
|
|
"%d": "dd",
|
|
"%a": "ddd",
|
|
"%A": "dddd",
|
|
}
|
|
|
|
|
|
def strftime_format_to_spreadsheet_time_format(strf_format):
|
|
"""Convert a strftime format to a spreadsheet time format.
|
|
"""
|
|
|
|
twelve_hour_system = False
|
|
parts = []
|
|
for part in re.finditer(r"(%.)", strf_format):
|
|
symbol = part.group(1)
|
|
spreadsheet_symbol = strftime_to_spreadsheet_time_format_table.get(symbol)
|
|
if spreadsheet_symbol:
|
|
parts.append(spreadsheet_symbol)
|
|
if symbol == "%I" or symbol == "%p":
|
|
twelve_hour_system = True
|
|
|
|
separator = re.search(r"(:| )", strf_format)
|
|
separator = separator.group(1) if separator else ":"
|
|
|
|
return separator.join(parts) + (" a" if twelve_hour_system else "")
|
|
|
|
def strftime_format_to_spreadsheet_date_format(strf_format):
|
|
"""Convert a strftime format to a spreadsheet date format.
|
|
"""
|
|
parts = []
|
|
for part in re.finditer(r"(%.)", strf_format):
|
|
symbol = part.group(1)
|
|
spreadsheet_symbol = strftime_to_spreadsheet_dateformat_table.get(symbol)
|
|
if spreadsheet_symbol:
|
|
parts.append(spreadsheet_symbol)
|
|
|
|
separator = re.search(r"(/|-| )", strf_format)
|
|
separator = separator.group(1) if separator else "/"
|
|
|
|
return separator.join(parts)
|