protobin 0.0.12__tar.gz → 0.0.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {protobin-0.0.12 → protobin-0.0.13}/PKG-INFO +1 -1
- {protobin-0.0.12 → protobin-0.0.13}/protobin/fields.py +5 -5
- {protobin-0.0.12 → protobin-0.0.13}/pyproject.toml +1 -1
- {protobin-0.0.12 → protobin-0.0.13}/.gitignore +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/LICENSE.txt +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/README.md +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/protobin/__init__.py +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/protobin/errors.py +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/protobin/interfaces.py +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/protobin/protocol.py +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/tests/demo.json +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/tests/demo.yaml +0 -0
- {protobin-0.0.12 → protobin-0.0.13}/tests/tests.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.13
|
|
4
4
|
Summary: Python library for encode and decode data in protobin format
|
|
5
5
|
Project-URL: Homepage, https://github.com/drmelectronic/protobin-python
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/drmelectronic/protobin-python/issues
|
|
@@ -225,7 +225,7 @@ class DateField(FieldBase):
|
|
|
225
225
|
|
|
226
226
|
def to_binary(self, val: datetime.datetime | str):
|
|
227
227
|
if val is None:
|
|
228
|
-
|
|
228
|
+
return bytes([0] * 3)
|
|
229
229
|
elif isinstance(val, str):
|
|
230
230
|
val = datetime.datetime.strptime(val, '%Y-%m-%d').date()
|
|
231
231
|
return bytes([
|
|
@@ -238,7 +238,7 @@ class DateField(FieldBase):
|
|
|
238
238
|
d, binary = self.get_nible(binary)
|
|
239
239
|
m, binary = self.get_nible(binary)
|
|
240
240
|
y, binary = self.get_nible(binary)
|
|
241
|
-
if y == 0 and m ==
|
|
241
|
+
if y == 0 and m == 0 and d == 0:
|
|
242
242
|
return None
|
|
243
243
|
return datetime.datetime(2000 + y, m, d).date()
|
|
244
244
|
|
|
@@ -254,9 +254,9 @@ class DateTimeField(FieldBase):
|
|
|
254
254
|
|
|
255
255
|
def to_binary(self, val: datetime.datetime | str):
|
|
256
256
|
if val is None:
|
|
257
|
-
|
|
257
|
+
return bytes([0] * 6)
|
|
258
258
|
elif not isinstance(val, datetime.datetime):
|
|
259
|
-
|
|
259
|
+
raise ValueError(f'Error in field "{self.key}", a datetime is expected but "{val}" is received')
|
|
260
260
|
elif isinstance(val, str):
|
|
261
261
|
val = datetime.datetime.strptime(val, '%Y-%m-%d %H:%M:%S').date()
|
|
262
262
|
return bytes([
|
|
@@ -275,7 +275,7 @@ class DateTimeField(FieldBase):
|
|
|
275
275
|
H, binary = self.get_nible(binary)
|
|
276
276
|
M, binary = self.get_nible(binary)
|
|
277
277
|
S, binary = self.get_nible(binary)
|
|
278
|
-
if y == 0 and m ==
|
|
278
|
+
if y == 0 and m == 0 and d == 0 and H == 0 and M == 0 and S == 0:
|
|
279
279
|
return None
|
|
280
280
|
return datetime.datetime(2000 + y, m, d, H, M, S)
|
|
281
281
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|