|
56 | 56 | string_types = str |
57 | 57 |
|
58 | 58 | EMPTYANNOTATION = "EMPTYLIST" |
| 59 | +DATETIMEANNOTATION = "DATETIME" |
59 | 60 | ARRAYANNOTATION = "ARRAYANNOTATION" |
60 | 61 | MIN_NIX_VER = Version("1.5.0") |
61 | 62 |
|
@@ -1162,7 +1163,8 @@ def _write_property(self, section, name, v): |
1162 | 1163 | section.create_property(name, v.magnitude.item()) |
1163 | 1164 | section.props[name].unit = str(v.dimensionality) |
1164 | 1165 | elif isinstance(v, datetime): |
1165 | | - section.create_property(name, calculate_timestamp(v)) |
| 1166 | + prop = section.create_property(name, calculate_timestamp(v)) |
| 1167 | + prop.definition = DATETIMEANNOTATION |
1166 | 1168 | elif isinstance(v, string_types): |
1167 | 1169 | if len(v): |
1168 | 1170 | section.create_property(name, v) |
@@ -1201,8 +1203,7 @@ def _write_property(self, section, name, v): |
1201 | 1203 | values.append(item) |
1202 | 1204 | section.create_property(name, values) |
1203 | 1205 | section.props[name].unit = unit |
1204 | | - if definition: |
1205 | | - section.props[name].definition = definition |
| 1206 | + section.props[name].definition = definition |
1206 | 1207 | elif type(v).__module__ == "numpy": |
1207 | 1208 | section.create_property(name, v.item()) |
1208 | 1209 | else: |
@@ -1242,6 +1243,8 @@ def _nix_attr_to_neo(nix_obj): |
1242 | 1243 | neo_attrs['array_annotations'][prop.name] = values |
1243 | 1244 | else: |
1244 | 1245 | neo_attrs['array_annotations'] = {prop.name: values} |
| 1246 | + elif prop.definition == DATETIMEANNOTATION: |
| 1247 | + values = datetime.fromtimestamp(values) |
1245 | 1248 | else: |
1246 | 1249 | neo_attrs[prop.name] = values |
1247 | 1250 | # since the 'neo_name' NIX property becomes the actual object's name, |
|
0 commit comments