Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created time offset set to 53min28s for no reason #142

Open
szaiser opened this issue Mar 18, 2024 · 6 comments
Open

Created time offset set to 53min28s for no reason #142

szaiser opened this issue Mar 18, 2024 · 6 comments
Assignees
Labels
in-progress Issue is currently being resolved by a developer. no-stale This issue or PR is exempted from the stale bot. priority-low Nice addition, maybe... someday...

Comments

@szaiser
Copy link

szaiser commented Mar 18, 2024

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.

@tb1337 tb1337 self-assigned this Mar 19, 2024
@tb1337
Copy link
Owner

tb1337 commented Mar 19, 2024

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?

@szaiser
Copy link
Author

szaiser commented Mar 19, 2024

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.

@szaiser
Copy link
Author

szaiser commented Mar 21, 2024

@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) yields
    datetime.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) yields
    datetime.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.

Copy link
Contributor

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.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Apr 21, 2024
@tb1337 tb1337 added no-stale This issue or PR is exempted from the stale bot. and removed stale There has not been activity on this issue or PR for quite some time. labels Apr 21, 2024
@tb1337
Copy link
Owner

tb1337 commented Apr 21, 2024

Reactivated. I am just on vacation.

@tb1337 tb1337 added in-progress Issue is currently being resolved by a developer. priority-low Nice addition, maybe... someday... labels May 8, 2024
@tb1337
Copy link
Owner

tb1337 commented May 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-progress Issue is currently being resolved by a developer. no-stale This issue or PR is exempted from the stale bot. priority-low Nice addition, maybe... someday...
Projects
None yet
Development

No branches or pull requests

2 participants