Improve auto-handling of "local" timestamps
for non-Rattail DBs where timestamps are local instead of UTC
This commit is contained in:
parent
d2d632092b
commit
72177e8ab5
3 changed files with 27 additions and 5 deletions
|
@ -424,6 +424,7 @@ class MasterView(View):
|
|||
'url': lambda obj: self.get_action_url('view', obj),
|
||||
'checkboxes': checkboxes,
|
||||
'checked': self.checked,
|
||||
'assume_local_times': self.has_local_times,
|
||||
}
|
||||
if 'main_actions' not in kwargs and 'more_actions' not in kwargs:
|
||||
main, more = self.get_grid_actions()
|
||||
|
@ -2961,6 +2962,16 @@ class MasterView(View):
|
|||
Coerce the given data dict record, to a "row" dict suitable for use
|
||||
when writing directly to XLSX file.
|
||||
"""
|
||||
data = dict(data)
|
||||
for key in data:
|
||||
value = data[key]
|
||||
|
||||
# make timestamps local, "zone-naive"
|
||||
if isinstance(value, datetime.datetime):
|
||||
value = localtime(self.rattail_config, value, tzinfo=False)
|
||||
|
||||
data[key] = value
|
||||
|
||||
return data
|
||||
|
||||
def results_csv(self):
|
||||
|
@ -3504,6 +3515,7 @@ class MasterView(View):
|
|||
'model_class': getattr(self, 'model_class', None),
|
||||
'action_url': self.request.current_route_url(_query=None),
|
||||
'use_buefy': self.get_use_buefy(),
|
||||
'assume_local_times': self.has_local_times,
|
||||
}
|
||||
if self.creating:
|
||||
kwargs.setdefault('cancel_url', self.get_index_url())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue