Skip to content

Commit 3ebe51b

Browse files
committed
Render JSON dates as timestamp integers
Fixes: #113 SemVer: bugfix
1 parent 7b8bbfe commit 3ebe51b

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

caso/messenger/ssm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def push(self, records):
193193
aux = []
194194
for k, v in six.iteritems(record.dict(**opts)):
195195
if v is not None:
196+
# FIXME(aloga): to be handled at record level.
196197
if isinstance(v, datetime.datetime):
197198
aux.append(f"{k}: {int(v.timestamp())}")
198199
else:

caso/record.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def map_fields(field: str) -> str:
189189
}
190190
return d.get(field, field)
191191

192+
json_encoders = {datetime: lambda v: int(v.timestamp())}
192193
alias_generator = map_fields
193194
allow_population_by_field_name = True
194195
underscore_attrs_are_private = True
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes issue 115, where timestamps where incorrecly rendered. This fix
5+
requires a republish of records.

0 commit comments

Comments
 (0)