Commits

Ada Young  committed 7b4a3c1

Fixed timestamp handling for received messages to compensate for the lack of year in timestamp

  • Participants
  • Parent commits d06523d

Comments (0)

Files changed (1)

File messagedb.xml

 timestamp = timestamp.split('/')
 year = datetime.now().year
 (month, day, time) = timestamp
-if len(time) < 5:
-    time = "0" + time
-if len(month) < 2:
-    month = "0" + month
-if len(day) < 2:
-    day = "0" + day
-timestamp = "%s-%s-%s %s:00" % (year, month, day, time)
+(hour, minute) = time.split(":")
+
+year = int(year)
+month = int(month)
+day = int(day)
+hour = int(hour)
+minute = int(minute)
+
+timestamp = datetime(year, month, day, hour, minute)
+if timestamp > datetime.now():
+    year -= 1 # subtract one year from timestamp if it seems to be from the future
+
+timestamp = datetime(year, month, day, hour, minute).strftime("%Y-%m-%d %H:%M:%S")
 message_text.append(' '.join(message_chunks[1:]))
 world.EnableTrigger("MessageCaptureFL", False)
 world.EnableTrigger("MessageCapture", True)