dropbox / dropbox/nsot

Timezone calculation error: NSoT should set UTC by default.

Open
#327 1 comment 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Python
Stars
407
Forks
61
PR merge metrics
No merged PRs in 30d

Description

I am running NSOT in an lxd container which has UTC as its timezone.

When creating or editing anything in the NSOT GUI, the changelog tells me that the change happened "5 hours ago".

I believe this is to do with the Django legacy default [TIME_ZONE](https://docs.djangoproject.com/en/1.8/ref/settings/#time-zone) which is `America/Chicago`

I suggest that the default generated `nsot.conf.py` have `TIME_ZONE = 'UTC'`, because this is what Django does for new projects:

> Since Django was first released with the TIME_ZONE set to 'America/Chicago', the global setting (used if nothing is defined in your project’s settings.py) remains 'America/Chicago' for backwards compatibility. New project templates default to 'UTC'.

When I change this setting, all the existing changes still say they happened "5 hours ago", but new changes are "a few seconds ago". It appears that dates are stored in local time.

A modern Django project will have [USE_TZ=True](https://docs.djangoproject.com/en/1.8/ref/settings/#use-tz) and maybe that ought to be used as well.

> The default settings.py file created by django-admin startproject includes USE_TZ = True for convenience.

This might mean that timestamps are stored in the database as UTC, regardless of the display timezone, which would be better.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.