Commits

b7w  committed 957eab5

Add time zone for time that came from exif

  • Participants
  • Parent commits 0359637

Comments (0)

Files changed (3)

File bviewer/core/images.py

 import os
 import random
 import logging
-
+from django.utils.timezone import utc
 from django.conf import settings
 from PIL import Image, ImageDraw, ImageFont
 from PIL.ExifTags import TAGS
         time = self._data.get('DateTimeOriginal', None)
         if time:
             try:
-                return datetime.strptime(time, '%Y:%m:%d %H:%M:%S')
+                return datetime.strptime(time, '%Y:%m:%d %H:%M:%S').replace(tzinfo=utc)
             except ValueError:
                 logger.warning('Wrong datetime "%s" in "%s" file', time, self.image_path)
 

File bviewer/core/tests/test_images.py

 # -*- coding: utf-8 -*-
 from datetime import datetime
+from django.utils.timezone import utc
 
 from bviewer.core.images import CacheImage
 from bviewer.core.tests.base import BaseImageStorageTestCase
 
         exif = self.storage.exif(self.path)
         exif._data = dict(DateTimeOriginal='2013:04:14 12:00:01')
-        self.assertEqual(exif.ctime, datetime(2013, 4, 14, 12, 0, 1))
+        self.assertEqual(exif.ctime, datetime(2013, 4, 14, 12, 0, 1, tzinfo=utc))

File docs/ref/architecture.rst

   *If parent is None it will be hidden from gallery tree for holder too.*
   **Gallery sorting** - Sort order of the nested galleries on time.
   ASK - Ascending, DESK - Descending.
+  **allow_archiving** - Allow users to download images in archive
   **Thumbnail** - image of gallery tile.
 
 .. code-block:: python
         user = models.ForeignKey(ProxyUser)
         visibility = models.SmallIntegerField(max_length=1, choices=VISIBILITY_CHOICE, default=VISIBLE)
         gallery_sorting = models.SmallIntegerField(max_length=1, choices=SORT_CHOICE, default=ASK)
+        allow_archiving = models.BooleanField(default=True)
         description = models.TextField(max_length=512, null=True)
         thumbnail = models.ForeignKey('Image', null=True)
         time = models.DateTimeField(default=datetime.now)