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

Use config timezone in all displayed times #326

Merged
merged 3 commits into from
May 26, 2021
Merged

Use config timezone in all displayed times #326

merged 3 commits into from
May 26, 2021

Conversation

Nixinova
Copy link
Contributor

Adds timeZone argument to the date constructor in the recent activity plugin to add a timezone to the times. Should make it so that the times all display in the user's set timezone.
Haven't tested it though.
Fixes #324.

@Nixinova Nixinova marked this pull request as draft May 25, 2021 19:29
@Nixinova Nixinova changed the title Use config timezone in recent activity times Use config timezone in all displayed times May 25, 2021
@Nixinova
Copy link
Contributor Author

It would be easier to set the timezone in utils.js wouldnt it. Is config available in there?

@lowlighter
Copy link
Owner

config is not available in utils.js since it would require to load and parse inputs unfortunately 😕
Since config.timezone can be defined per user on web instance, it's not possible to set it globally directly neither.

I agree it's not very practical, so maybe a good solution would be to transform the formatters into a class-like object so we can pass it some options to them by instantiating them like imports.format({timezone:config.timezone?.name})? Then we would just need to patch it before calling the EJS renderer:

rendered = await ejs.render(rendered, {...data, s:imports.s, f:imports.format, embed}, {views, async:true, ...delimiters})

@Nixinova
Copy link
Contributor Author

Maybe instead change the formatter to use predefined templates? Like "date" and "datetime" because you only use dateStyle:short or dateStyle:short,timeStyle:short.

@lowlighter lowlighter merged commit 19552e2 into lowlighter:master May 26, 2021
@lowlighter lowlighter mentioned this pull request May 26, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recent activity times are in UTC instead of the set timezone
2 participants