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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: protobin
3
- Version: 0.0.12
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
- val = datetime.datetime(2000, 1, 1)
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 == 1 and d == 1:
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
- val = datetime.datetime(2000, 1, 1)
257
+ return bytes([0] * 6)
258
258
  elif not isinstance(val, datetime.datetime):
259
- raise ValueError(f'Error in field "{self.key}", a datetime is expected but "{val}" is received')
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 == 1 and d == 1 and H == 0 and M == 0 and S == 0:
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
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "protobin"
7
- version = "0.0.12"
7
+ version = "0.0.13"
8
8
  authors = [
9
9
  { name="Daniel Robles", email="drm.electronic@gmail.com" },
10
10
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes