paperless-api
paperless-api copied to clipboard
Created time offset set to 53min28s for no reason
I created a document via
import datetime
from paperlessApi.read_info import get_paperless
paperless = get_paperless()
async with paperless as p:
draft = p.documents.draft()
draft.document = open('./test.pdf', 'rb').read()
draft.title='thisisthetitle'
draft.created=datetime.datetime(year=1001, month=2, day=3)
await draft.save()
The created document has a weird timezone offset of 53:28
paperless = get_paperless()
async with paperless as p:
document_data = []
async with p.documents.reduce(id=917) as filtered:
async for document in filtered:
print(document.created)
Output:
1001-02-03 00:53:28+00:53:28
The object is equally weird:
document.created
yields
datetime.datetime(1001, 2, 3, 0, 53, 28, tzinfo=datetime.timezone(datetime.timedelta(seconds=3208)))
This by the way is not one time, it happens on other documents as well and is independent of the current time. Any idea whats going on there? I would do some investigation myself, but my debugging skills stopped at the async functions.
Hey there, okay, that should not happen. Can you please tell me the value of the TZ attribute you have configured to your Paperless-ngx, and which one you are running locally on your device?
Hi! Both timezones are set to +1:00, timestamps from paperless logs also match my current windows time. From what I can tell, those settings are ok.
@tb1337 I created two additional documents, identical to the ones in my original post but with different created times:
draft.created=datetime.datetime(year=1001, month=2, day=3, hour=11, minute=12, second=55)yieldsdatetime.datetime(1001, 2, 3, 12, 6, 23, tzinfo=datetime.timezone(datetime.timedelta(seconds=3208)))draft.created=datetime.datetime(year=2023, month=2, day=3, hour=11, minute=12, second=55)yieldsdatetime.datetime(2023, 2, 3, 12, 12, 55, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))
So unless you are a historian or do tests with very weird numbers (like me), you will never notice this bug. If it does not make you feel uncomfortable to have this timezone bug buried somewhere, feel free to close the ticket. I will now stick to non-historian times.
There hasn't been any activity on this issue recently, so we have to clean up some inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you.
Reactivated. I am just on vacation.
Hey, I can reproduce the behavior, but currently I think it's a Paperless-ngx thing. Gonna check the Paperless-ngx code for any reason for what is happening here. PyPaperless does actually send a well-formatted timestamp with timezone information (for example +00:00 or +02:00), but after the document got consumed by Paperless-ngx, the API returns that weird stuff.
There hasn't been any activity on this issue recently, so we have to clean up some inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you.
The latest release contains some bugfixes around creation date. Not sure if this will fix the problem here.