Skip to content

Commit

Permalink
Merge pull request #11 from Savage-Aim/timezone-fix
Browse files Browse the repository at this point in the history
Timezone fix
  • Loading branch information
freyamade authored Feb 18, 2022
2 parents 886a592 + b140a04 commit 4c3082f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions backend/api/management/commands/fix_timestamps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import timezone
from django.core.management.base import BaseCommand
from api.models import Character, Notification


class Command(BaseCommand):
help = 'Fix all the Timestamps in the DB that are missing tzinfo'

def handle(self, *args, **options):
for obj in Character.objects.all():
if obj.created.tzinfo is None:
self.stdout.write(f'Updating created stamp for {obj}')
obj.created = obj.created.astimezone(timezone.utc)
obj.save()

for obj in Notification.objects.all():
if obj.timestamp.tzinfo is None:
self.stdout.write(f'Updating timestamp for {obj}')
obj.timestamp = obj.timestamp.astimezone(timezone.utc)
obj.save()
8 changes: 8 additions & 0 deletions backend/backend/settings_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@
},
}

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True

# Sentry for errors as well
def sampler(context):
# Always inherit parent context
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/modals/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<h2 class="has-text-primary subtitle">{{ version }}</h2>
<div class="divider"><i class="material-icons icon">expand_more</i> Minor Changes <i class="material-icons icon">expand_more</i></div>
<p>Loot Tracker Greed Boxes will always have every Character in them, even if they don't have a BIS list, just for QoL.</p>

<div class="divider"><i class="material-icons icon">expand_more</i> Bugfixes <i class="material-icons icon">expand_more</i></div>
<p>Fixed an issue where Notification timestamps were not stored in UTC, causing issues for displaying them in other timezones.</p>
</div>
</div>
</template>
Expand Down

0 comments on commit 4c3082f

Please sign in to comment.