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] Timestamp mismatch #453

Open
rwejdling opened this issue Feb 8, 2024 · 3 comments · May be fixed by #461
Open

[BUG] Timestamp mismatch #453

rwejdling opened this issue Feb 8, 2024 · 3 comments · May be fixed by #461
Assignees
Labels
bug Something isn't working

Comments

@rwejdling
Copy link

Describe the bug
Timestamp in incident updates aren't matching the configured timezone.

Version
1.10.1 and previous versions (just never got around to reporting it)

To Reproduce
Steps to reproduce the behavior:

  1. Set timezone: CET or timezone: Europe/Copenhagen in config.yaml
  2. Post an update on a incident
  3. Validate that the Posted At: timestamp on the update in digest channel is actually correct

Expected behavior
Set posted at to the correct timestamp

Screenshots
image

Environment (please complete the following information):

  • Platform: container running on ECS

Additional context
N/A

@rwejdling rwejdling added the bug Something isn't working label Feb 8, 2024
@rwejdling
Copy link
Author

rwejdling commented Feb 8, 2024

Actually all timestamps are one hour off:
image
image

I'm currently in Copenhagen which is CET (GMT+1).

@uptickmetachu
Copy link

I believe this might be because all the timestamps are currently stored as strings with the timestamp embedded in them:

updated_at is 2024-02-13T20:53:20 AEDT.

Would it be feasible to refactor the time columns from string/varchar to utc timestamps and then render them to the users specified timezone? @echoboomer

@uptickmetachu
Copy link

application_timezone = 'Europe/Copenhagen'


def fetch_timestamp(short: bool = False):
    """Return a localized, formatted timestamp using datetime.now()"""
    now = datetime.now()
    localized = timezone(application_timezone).localize(now)
    if short:
        return localized.strftime(timestamp_fmt_short)
    return localized.strftime(timestamp_fmt)

This seems to be the problem.

def fetch_timestamp(short: bool = False):

This should be


    now = datetime.datetime.now(datetime.UTC)
    localized = now.astimezone(timezone(application_timezone))
    if short:
        return localized.strftime(timestamp_fmt_short)
    return localized.strftime(timestamp_fmt)

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

Successfully merging a pull request may close this issue.

3 participants