Python 2.7 datetime object returning a value of 60 seconds
<p>I have the following bit of code I use to generate timestamps from a lot of instruments.  The data gets logged into an initial SQLite database when it is read (w/o milliseconds), then logged into a second database when it's transmitted (w. milliseconds).  After several days of data capture, I find that there are a couple times per night where I end up with a logged time that ends with 60 seconds (vs 00 or 59).  </p>

<p>I understand that Python has some support for leap seconds, but I know that there weren't any during the nights I was recording data. Also, datetime doesn't support seconds greater than 59.  Anyway, I don't know what's going on, and I haven't been able to reproduce the problem by hand.  I was hoping someone else might have seen this behavior before.</p>

<p>So, as an example, in my first log I have the entry 20160823043460, and in my transmit log I have 20160823043500.01.</p>

<p>Here's my timestamp code.  (Yes, I know it's odd that everything doesn't get the same timestamp, but I  didn't design the spec, I'm just coding to it)</p>

<pre><code>def makeTimeStamp(time=None, miliseconds=False):
    timeStamp = ""
    if time is None and miliseconds is False:
        timeStamp = datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S")
    #time format: YYYY MM DD HH MM SS as one string
    elif time is None and miliseconds is True:
        timeStamp = datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S.%f")
    else:
        try:
            timeStamp = time.strftime("%Y%m%d%H%M%S")
        except AttributeError:
            print "error:  attempted to make a timestamp from a " + type(time)
    return timeStamp
</code></pre>

<p>Check python docs for time library, <a href="https://docs.python.org/2/library/time.html#time.strftime" rel="nofollow" title="time">here</a>.</p>

<p>In the notes, under 2, it says that the range for seconds is really [0, 61].</p>

python sqlite datetime