I have found what seems to be a little bug in the datetime package in
Python 3.9.13.
I was working with `datetime.datetime.now().microsecond`, which should
return the microsecond of the current time - it does so, but the value is
returned as an integer.
This means that leading zeros of the value will be cropped, and the
isolated value of the `.microsecond` will be flawed.
This is code in use. Here the full timestamp from
`datetime.datetime.now().microsecond` is printed together with the
re-combined timestamp from `datetime.datetime.now().year`, `.month`,
`.day`, `.hour`, `.minute`, `.second` and `.microsecond`:
```
max_iter = 10
i = 0
temp_sec = None
while True:
time_now = datetime.datetime.now()
sec = time_now.second
if sec % 1 == 0 and sec != temp_sec:
i += 1
print(time_now.strftime("%Y-%m-%d %H:%M:%S.%f"))
print(time_now.year, time_now.month, time_now.day, '',
(str(time_now.hour)+':'+str(time_now.minute)+
':'+str(time_now.second)+'.'
+str(time_now.microsecond)) )
print()
temp_sec = sec
if i > max_iter:
break
time.sleep(0.01)
```
```
Output:
>>> 2023-04-14 12:21:43.004813
>>> 2023 4 14 12:21:43.4813
...
```
This seems like a bug to me.
Best regards
- August Birk