I'm using Python 2.6.6 and PyQt4. I have a start QDateTime object and I am iteratively adding 60 seconds to create a list of every minute within a given time span. I have discovered that there are several cases where adding two different segundos values to the QDateTime object produces the same time.
Aquí tienes un ejemplo del problema:
from PyQt4 import QtCore start = QtCore.QDateTime.fromString("2010-11-01 00:00", "yyyy-MM-dd hh:mm") print start.addSecs(522540).toString("yyyy-MM-dd hh:mm") print start.addSecs(526140).toString("yyyy-MM-dd hh:mm")
Y la salida resultante:
2010-11-07 01:09 2010-11-07 01:09
I've been banging my head on the keyboard trying to figure this out. What am I doing incorrectly?
preguntado el 03 de mayo de 12 a las 18:05
it probably depends on your locale settings:
parece DST in the United States and other countries terminó el
so i'd bet it's a result of that.
if you get any strange values from doing calculations with dates, always check if there hasn't been DST change or a leap year and consider different locales. sadly time isn't always as linear as it seems.