8000 Allow displaying times in users local timezone by multimac · Pull Request #157 · cstate/cstate · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow displaying times in users local timezone #157

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

Closed
wants to merge 1 commit into from

Conversation

multimac
Copy link

This commit adds a new config parameter, useLocalTime (defaulted to false for backwards compatibility).

When set to true, cState will render all dates in the UI as ISO8601 dates and add some Javascript to update these dates to the users local timezone. This PR ensures the incident history grouping is also done in the users local timezone if enabled.

This change only applies to dates rendered in the UI, and not those in the JSON API, these remain in UTC time (though the PR does update the Hugo generation to explicitly use UTC dates).

One downside of altering the dates using Javascript to format the dates is that the dateFormat and shortDateFormat variables are no longer useful, as these are in the Golang-specific date format.

Before, incident history:
image

Before, specific incident:
image

After, incident history (note, I'm in Australia / UTC+10):
image

After, specific incident:
image

closes #123

This commit adds a new config parameter, useLocalTime (defaulted to
false for backwards compatibility), which allows rendering dates in a
users local timezone instead of UTC.
@multimac
Copy link
Author

I just realised the similar logic in the "Next Release Dev PR" (#151).

I feel like having local times might still be useful but this code is nowhere near as nice as the relative-time logic in that PR, so happy if you want to reject this. If I get time I might try and refactor the code to be a bit nicer.

One benefit this PR does have is that the incident-history pages are grouped correctly (ie. when "yearly" or "monthly" is selected) by the users local timezone instead of UTC, but I'm not sure this is really that important compared.

@mistermantas
Copy link
Member
mistermantas commented Feb 24, 2021

Thanks for your earlier contribution, but I went with the other contribution as it was more versatile this way.

Progress - #151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Showing local time automatically with JS - timezone conundrum
2 participants
0