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

Bug: Uploaded date for files is invalid #278

Closed
maximmax42 opened this issue Jan 27, 2023 · 20 comments
Closed

Bug: Uploaded date for files is invalid #278

maximmax42 opened this issue Jan 27, 2023 · 20 comments
Labels
bug Something isn't working
Milestone

Comments

@maximmax42
Copy link
Contributor

maximmax42 commented Jan 27, 2023

What happened?

All (but one) of my files in the gallery show this instead of the actual date:
image
And one file shows this:
image
Except its actual upload date is this:
image

Something somewhere thinks that the date format is mm.dd.yyyy, even though both my host and my own pc use dd.mm.yyyy.

Dashboard's main page shows a proper upload date.

Version

upstream (ghcr.io/diced/zipline:trunk)

What browser(s) are you seeing the problem on?

Chromium-based (Chrome, Edge, Brave, Opera, mobile chrome/chromium based, etc)

Zipline Logs

No response

Browser Logs

No response

Additional Info

No response

@maximmax42 maximmax42 added the bug Something isn't working label Jan 27, 2023
@diced
Copy link
Owner

diced commented Jan 27, 2023

Not sure if this will fix it but, the path Zipline is on in the docker file is /app now, make sure your volumes use /app instead of /zipline.

@diced
Copy link
Owner

diced commented Jan 27, 2023

Something somewhere thinks that the date format is mm.dd.yyyy, even though both my host and my own pc use dd.mm.yyyy.

That's weird... It should be using your browsers locale format, which i'm guessing is probably dd.mm.yyy

@maximmax42
Copy link
Contributor Author

maximmax42 commented Jan 27, 2023

Not sure if this will fix it but, the path Zipline is on in the docker file is /app now, make sure your volumes use /app instead of /zipline.

I tried a build before the 70c2fa8 commit, same thing. But thanks, that should probably fix the other issue I've opened.

That's weird... It should be using your browsers locale format, which i'm guessing is probably dd.mm.yyy

Yup, dd.mm.yyyy everywhere.

@diced
Copy link
Owner

diced commented Jan 27, 2023

Yup, dd.mm.yyyy everywhere.

Hold on, is it using that format, or are you just saying it should be using that?

@maximmax42
Copy link
Contributor Author

maximmax42 commented Jan 27, 2023

It should be using dd.mm.yyyy, but somehow, and only in the gallery's file cards, it's trying to read a dd.mm.yyyy date as a mm.dd.yyyy.

@maximmax42
Copy link
Contributor Author

Creation time in the URL card in the /dashboard/urls also shows just fine.

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 1, 2023

Update: 3.5.1 displays everything just fine, 3.6.0 and onwards doesn't. Might be the relative time package?

@TacticalTechJay
Copy link
Collaborator

Do you have any sample data of any image directly from the db that has this problem?

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 3, 2023

COPY public."File" (id, name, mimetype, "createdAt", views, "userId", favorite, embed, format, password, "expiresAt", "maxViews", "originalName") FROM stdin;
12	72mBg.txt	text/plain	2022-10-28 10:55:33.642	86	1	f	t	RANDOM	\N	\N	\N	\N
23	hciKJ.mp4	video/mp4	2022-11-04 12:04:46.088	3	1	f	t	RANDOM	\N	\N	\N	\N

First one shows "NaN years ago" and "Invalid Date", second shows "10 months ago" and "11.04.2022, 17:04:46".
My system format is dd.mm.yyyy everywhere, timezone is UTC+5.

@maximmax42
Copy link
Contributor Author

I'm breaking my goddamn brain over this. I don't get it. Apparently new Date('2022-11-04 12:04:46.088') just doesn't produce a proper Date object. Is there any way to change the way how the dates are stored in the database to proper ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ)?

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 23, 2023

Uh... I see what the problem is apparently. Why is image.createdAt in

subtitle={relativeTime(new Date(image.createdAt))}
already a localized string (a la "23.02.2023, 19:04:11") instead of whatever format should be returned from the db? Is it because of this?
createdAt: new Date(x.createdAt).toLocaleString(),

Trying to do new Date("23.02.2023, 19:04:11") does indeed produce an incorrect date, but new Date('2023-02-23 19:04:11.000') would produce a proper date.

@TacticalTechJay
Copy link
Collaborator

TacticalTechJay commented Feb 23, 2023

You could try forking zipline and changing the end of this

createdAt: new Date(x.createdAt).toLocaleString(),

to toISOString().

@diced
Copy link
Owner

diced commented Feb 23, 2023

Uh... I see what the problem is apparently. Why is image.createdAt in

subtitle={relativeTime(new Date(image.createdAt))}

already a localized string (a la "23.02.2023, 19:04:11") instead of whatever format should be returned from the db? Is it because of this?

createdAt: new Date(x.createdAt).toLocaleString(),

Trying to do new Date("23.02.2023, 19:04:11") does indeed produce an incorrect date, but new Date('2023-02-23 19:04:11.000') would produce a proper date.

Ah.. I see, it shouldn't be localized at all in the file query.

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 23, 2023

You could try forking zipline and changing the end of this

createdAt: new Date(x.createdAt).toLocaleString(),

to toISOString().

Surprisingly, that didn't help. But now I have this.
image

Guess it's not that line in particular. Trying line 42.

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 23, 2023

Okay, so, yeah.

.then((data) => data.map((x) => ({ ...x, createdAt: new Date(x.createdAt).toLocaleString() })));
and
createdAt: new Date(x.createdAt).toLocaleString(),
need to be ISO strings. Or just untouched.

diced added a commit that referenced this issue Feb 23, 2023
@diced
Copy link
Owner

diced commented Feb 23, 2023

Can you take a look at the above commit and see if it fixes the issues you have?

I've just removed the toLocaleString from all of them, and replaced with Dates.

fdcd1f3

@maximmax42
Copy link
Contributor Author

maximmax42 commented Feb 24, 2023

Can you take a look at the above commit and see if it fixes the issues you have?

I've just removed the toLocaleString from all of them, and replaced with Dates.

fdcd1f3

Yeah, this works.
image

Except there's this mess now:
image

@TacticalTechJay
Copy link
Collaborator

Hmm... I suppose that's a step.

@maximmax42
Copy link
Contributor Author

So, e804d0b has fixed the previously mentioned mess, and it all looks nice.
image

With that, I think this issue can be closed.

@diced
Copy link
Owner

diced commented Feb 28, 2023

Yep! Forgot to let you know yesterday, my bad. If there are any more problems after this feel free to post another comment and reopen.

@diced diced added this to the 3.7.0 milestone Mar 22, 2023
diced added a commit that referenced this issue Mar 27, 2023
* fix: oauthId optional

* fix: remove optional

* hotfix: make oauthid optional (#249)

* hotfix: fallback oauth find (#250)

* fix: add a forgotten ? to schema

* fix: catch null at other places (#252)

* fix: forgor (#253)

* Fix root url & uploader stuff (#254)

* fix: uploader route as root won't be broken

* fix: fix broken url route for when on root

* fix: catch hopefully the most of the edge cases (#251)

* fix: catch hopefully the most of the edge cases

* fix: invite only, fools

* feat: tsup, small fixes

* fix: #264

* fix: urls handle empty strings

* fix: remove esbuild

* fix: do not mutate res #266

* feat: new embed method

* fix: overwrite tmp ss flameshot

* fix: overrides for uploading

* refactor: chart.js -> recharts

* feat: download query on /r/

* fix: better icons on file vie2

* feat: ability to generate url shorten config

* fix: sxcu name

* fix: react hooks error

* feat: ability to insert tabs on Tab keypress

* feat: overhaul image upload

* fix: clean

* fix: group icons vertically

* fix: embeds not showing up

* fix: docker stuff

* feat(3.7.0-rc1): version

* fix: cors for files (#257)

Co-authored-by: dicedtomato <[email protected]>

* refactor: many columns/tables in prisma

* feat: keep original name #247

* fix: ability to gen with original-name

* fix: type error

* fix: no name on dashboard

* feat(v3.7.0-rc2): version

* fix: sharex DestinationType

* fix: ensureDatabaseExists args

* fix: sharex config

* fix: #277 #272

* fix: 🐛 Add Menu component as parent

* refactor: popover -> menu

Co-authored-by: IceToast <>
Co-authored-by: dicedtomato <[email protected]>

* fix: add a "skip" for fresh db's (#274)

* fix: add a "skip" for fresh db's

* fix: trimming

* fix: elevate logging!

* fix: allow more variables on view

* fix: optimize docker image

* fix:  root url for upload and shorten (#255)

Co-authored-by: dicedtomato <[email protected]>

* fix: /app -> /zipline

* feat(v3.7.0-rc3): folders for files

* fix: use `name` instead of `file` (#281)

Co-authored-by: dicedtomato <[email protected]>

* feat: search+create for folder select (#283)

* feat?: Search for the folder to add.
Also you can create a folder right from the file, rather than being redirected.

* woops wrong import

* fix: return null for no string in parser (#285)

* feat: use ENTRYPOINT in docker (#286)

* :3

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* test

---------

Co-authored-by: dicedtomato <[email protected]>

* fix: set password to actual text value

* fix: url encode password query

* fix: entrypoint executable (#289)

* feat: override domain header

* fix: random domains

* feat: better version checking

* feat: public folders

* fix: dates #278

* feat: devcontainers for codespaces, etc.

* experiment with devcontainer.json

* introduce a docker-compose for devcontainer

* Devcontainers!

* version pop

* Port labeling and a complimentary env variable

* see it to believe it

* Update .devcontainer/devcontainer.json

* Update .devcontainer/devcontainer.json

* Update .devcontainer/docker-compose.yml

---------

Co-authored-by: dicedtomato <[email protected]>

* fix: spaces and route fixes (#294)

* fix: spaces and route fixes

* fix: shorten url response

* feat: better version checking

* fix: use special characters should work

If it doesn't, better call saul

* save that extra byte

* fix: returning protocol again in domain

unrelated to this pr but whatever

* fix: above ^

* Rename shorten.tsv to shorten.ts

---------

Co-authored-by: diced <[email protected]>
Co-authored-by: dicedtomato <[email protected]>

* fix: #296

* fix: show files per user (#299)

* feat: clearing orphaned files (#303)

* fix: default public folder (docker)

* feat: seperate discord webhooks (shorten/upload) (#260)

* fix: title for folders

* fix: clipboard & 2fa improvements

A workaround that shows the content that would have been copied if `navigator.clipboard` is unavailable for whatever reason.

2FA input autofocuses & submits on enter.

* fix: revamp uploaded file modal

* fix: revamp mobile ui

* feat: more functionality within files table

* feat: clear zero byte files script

* feat: logger improvements
- Timestamp is gray
- removed colorette dependency
- introduction of LOGGER_FILTERS

* chore: update deps

* feat(v3.7.0-rc4): version

* fix: show warning when password protect

* fix: fix (#310)

* Muted audio by default!

* Code renderin'

* not but still decently standard files being viewable

* reserved routes

* Update validateConfig.ts

---------

Co-authored-by: dicedtomato <[email protected]>

* feat: file size (#308)

* feat: baseline support for file sizes

* feat: script to add file sizes

* fix: #311

* chore: update to mantine@6

* refactor: remove old File.tsx

* feat: initial move to mantine v6

* feat: use api option

* remove: useless size modifier

* fix: user button

* feat: use pininput for 2fa

* fix: breaking changes in migrating mantine v6

---------

Co-authored-by: TacticalCoderJay <[email protected]>

* feat: add size to datatable

* fix: null on non originalName

* fix: allow download query on non raw

* fix: undef file

* fix: spacingg between count_by_user

* feat: new ui for shortened urls

* fix: spacing within appshell/paper

* feat: new login page

* feat: reorganize menu

* feat: keyboard spotlight

* feat: tabler icons

* fix: remove feather import

* fix: update 2fa enabled appropriately & delete files (#315)

* fix: update 2fa enabled appropriately

* fix: a proper delete

---------

Co-authored-by: dicedtomato <[email protected]>

* feat(v3.7.0-rc5): version

* feat: add feature request "contact_link"

* feat: multiple stuffs

* feat: gfycat url #322

* feat: gfycat attribution

* feat(3.7.0-rc6): version

* fix: type cast

* feat: list view for urls, invites, users: #302

* refactor: docker-compose -> docker compose

* fix: open folder in new tab

* fix: save list-view setting to localStorage

* fix: Bug: URLs list view #330

* fix: #332

* fix: #331

* fix: #333

* feat: link to view gallery (icon)

* fix: clean up Anchors

* refactor: new eslint changes

* fix: fine tune devcontainer (#329)

Co-authored-by: dicedtomato <[email protected]>

* fix: FileModal scrollbars

* fix: dynamically import katex

* fix: remove rogue console.log

* fix: open folder onRowClick

* fix: filter on usePaginatedFiles

* fix: icon sizes

* fix: paste listener

* feat(actions): auto-assign milestone

* feat(v3.7.0-rc7): version

* fix: #339

* fix: resetting avatars

* feat: new icons / oauth icons changed

* feat: UPLOADER_ASSUME_MIMETYPES (#337)

* fix: any instance of #342

* fix: any instance of #345

* fix: make tables take entire vh

* chore: update deps

* fix: add bigger sizeLimit

* fix: token exposed on view/[id]

---------

Co-authored-by: Jayvin Hernandez <[email protected]>
Co-authored-by: IceToast <[email protected]>
Co-authored-by: IThundxr <[email protected]>
Co-authored-by: IThundxr <[email protected]>
diced added a commit that referenced this issue Mar 27, 2023
* fix: oauthId optional

* fix: remove optional

* hotfix: make oauthid optional (#249)

* hotfix: fallback oauth find (#250)

* fix: add a forgotten ? to schema

* fix: catch null at other places (#252)

* fix: forgor (#253)

* Fix root url & uploader stuff (#254)

* fix: uploader route as root won't be broken

* fix: fix broken url route for when on root

* fix: catch hopefully the most of the edge cases (#251)

* fix: catch hopefully the most of the edge cases

* fix: invite only, fools

* feat: tsup, small fixes

* fix: #264

* fix: urls handle empty strings

* fix: remove esbuild

* fix: do not mutate res #266

* feat: new embed method

* fix: overwrite tmp ss flameshot

* fix: overrides for uploading

* refactor: chart.js -> recharts

* feat: download query on /r/

* fix: better icons on file vie2

* feat: ability to generate url shorten config

* fix: sxcu name

* fix: react hooks error

* feat: ability to insert tabs on Tab keypress

* feat: overhaul image upload

* fix: clean

* fix: group icons vertically

* fix: embeds not showing up

* fix: docker stuff

* feat(3.7.0-rc1): version

* fix: cors for files (#257)

Co-authored-by: dicedtomato <[email protected]>

* refactor: many columns/tables in prisma

* feat: keep original name #247

* fix: ability to gen with original-name

* fix: type error

* fix: no name on dashboard

* feat(v3.7.0-rc2): version

* fix: sharex DestinationType

* fix: ensureDatabaseExists args

* fix: sharex config

* fix: #277 #272

* fix: 🐛 Add Menu component as parent

* refactor: popover -> menu

Co-authored-by: IceToast <>
Co-authored-by: dicedtomato <[email protected]>

* fix: add a "skip" for fresh db's (#274)

* fix: add a "skip" for fresh db's

* fix: trimming

* fix: elevate logging!

* fix: allow more variables on view

* fix: optimize docker image

* fix:  root url for upload and shorten (#255)

Co-authored-by: dicedtomato <[email protected]>

* fix: /app -> /zipline

* feat(v3.7.0-rc3): folders for files

* fix: use `name` instead of `file` (#281)

Co-authored-by: dicedtomato <[email protected]>

* feat: search+create for folder select (#283)

* feat?: Search for the folder to add.
Also you can create a folder right from the file, rather than being redirected.

* woops wrong import

* fix: return null for no string in parser (#285)

* feat: use ENTRYPOINT in docker (#286)

* :3

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* Update Dockerfile

Co-authored-by: dicedtomato <[email protected]>

* test

---------

Co-authored-by: dicedtomato <[email protected]>

* fix: set password to actual text value

* fix: url encode password query

* fix: entrypoint executable (#289)

* feat: override domain header

* fix: random domains

* feat: better version checking

* feat: public folders

* fix: dates #278

* feat: devcontainers for codespaces, etc.

* experiment with devcontainer.json

* introduce a docker-compose for devcontainer

* Devcontainers!

* version pop

* Port labeling and a complimentary env variable

* see it to believe it

* Update .devcontainer/devcontainer.json

* Update .devcontainer/devcontainer.json

* Update .devcontainer/docker-compose.yml

---------

Co-authored-by: dicedtomato <[email protected]>

* fix: spaces and route fixes (#294)

* fix: spaces and route fixes

* fix: shorten url response

* feat: better version checking

* fix: use special characters should work

If it doesn't, better call saul

* save that extra byte

* fix: returning protocol again in domain

unrelated to this pr but whatever

* fix: above ^

* Rename shorten.tsv to shorten.ts

---------

Co-authored-by: diced <[email protected]>
Co-authored-by: dicedtomato <[email protected]>

* fix: #296

* fix: show files per user (#299)

* feat: clearing orphaned files (#303)

* fix: default public folder (docker)

* feat: seperate discord webhooks (shorten/upload) (#260)

* fix: title for folders

* fix: clipboard & 2fa improvements

A workaround that shows the content that would have been copied if `navigator.clipboard` is unavailable for whatever reason.

2FA input autofocuses & submits on enter.

* fix: revamp uploaded file modal

* fix: revamp mobile ui

* feat: more functionality within files table

* feat: clear zero byte files script

* feat: logger improvements
- Timestamp is gray
- removed colorette dependency
- introduction of LOGGER_FILTERS

* chore: update deps

* feat(v3.7.0-rc4): version

* fix: show warning when password protect

* fix: fix (#310)

* Muted audio by default!

* Code renderin'

* not but still decently standard files being viewable

* reserved routes

* Update validateConfig.ts

---------

Co-authored-by: dicedtomato <[email protected]>

* feat: file size (#308)

* feat: baseline support for file sizes

* feat: script to add file sizes

* fix: #311

* chore: update to mantine@6

* refactor: remove old File.tsx

* feat: initial move to mantine v6

* feat: use api option

* remove: useless size modifier

* fix: user button

* feat: use pininput for 2fa

* fix: breaking changes in migrating mantine v6

---------

Co-authored-by: TacticalCoderJay <[email protected]>

* feat: add size to datatable

* fix: null on non originalName

* fix: allow download query on non raw

* fix: undef file

* fix: spacingg between count_by_user

* feat: new ui for shortened urls

* fix: spacing within appshell/paper

* feat: new login page

* feat: reorganize menu

* feat: keyboard spotlight

* feat: tabler icons

* fix: remove feather import

* fix: update 2fa enabled appropriately & delete files (#315)

* fix: update 2fa enabled appropriately

* fix: a proper delete

---------

Co-authored-by: dicedtomato <[email protected]>

* feat(v3.7.0-rc5): version

* feat: add feature request "contact_link"

* feat: multiple stuffs

* feat: gfycat url #322

* feat: gfycat attribution

* feat(3.7.0-rc6): version

* fix: type cast

* feat: list view for urls, invites, users: #302

* refactor: docker-compose -> docker compose

* fix: open folder in new tab

* fix: save list-view setting to localStorage

* fix: Bug: URLs list view #330

* fix: #332

* fix: #331

* fix: #333

* feat: link to view gallery (icon)

* fix: clean up Anchors

* refactor: new eslint changes

* fix: fine tune devcontainer (#329)

Co-authored-by: dicedtomato <[email protected]>

* fix: FileModal scrollbars

* fix: dynamically import katex

* fix: remove rogue console.log

* fix: open folder onRowClick

* fix: filter on usePaginatedFiles

* fix: icon sizes

* fix: paste listener

* feat(actions): auto-assign milestone

* feat(v3.7.0-rc7): version

* fix: #339

* fix: resetting avatars

* feat: new icons / oauth icons changed

* feat: UPLOADER_ASSUME_MIMETYPES (#337)

* fix: any instance of #342

* fix: any instance of #345

* fix: make tables take entire vh

* chore: update deps

* fix: add bigger sizeLimit

* fix: token exposed on view/[id]

* feat(3.7.0): version

---------

Co-authored-by: Jayvin Hernandez <[email protected]>
Co-authored-by: IceToast <[email protected]>
Co-authored-by: IThundxr <[email protected]>
Co-authored-by: IThundxr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants