Title: Signature.html
My concern is probably not as great as I originally thought. Losing 1 second because of truncation of seconds is probably not all that bad. If I'm losing 1 second after 10 days or 1 day, that's not all that bad. The program is not to be a cure all for clock drift.

I guess I was alarmed that I might get into a situation where 2.7 would represented as 2, 4, 6, 8, ... as 2.7 was "added" to seconds for each 24 hours passed the base. However, I'm recalculating based on multiplication and not addition, so the times would be 2, 5 (2.7*2), 7 (2.7*3), ... 27 (2.7*10 and not 20), ...

Kent Johnson wrote:
On Wed, Sep 10, 2008 at 8:13 PM, Wayne Watson
<[EMAIL PROTECTED]> wrote:
  
I'd like to allow a user to enter a drift rate in seconds per day into a
program along with the date and time, a base, to begin calculation of
subsequent recorded date and times. datetime seems to only allow  hours,
minutes and seconds in its formats.  For example, 2.74 might be entered.
Using 2.74 for a time that's 24 hours from the base would cause me to record
the increase as 2 seconds. How can I account for fractional increases? I see
that the tuple allows for microseconds, but I'm not sure arithmetic or
formatting is allowed on it.
    

I don't really understand your problem statement, maybe a better
example would help?

Anyway both datetime and timedelta support microseconds so I think the
basic mechanism is there in the data structures. What is missing is
support in strptime() / strftime(). You can easily tack on
milliseconds to a formatted date. For example,

In [1]: from datetime import datetime, timedelta
In [4]: n
Out[4]: datetime.datetime(2008, 9, 10, 21, 31, 39, 937000)

In [8]: n.strftime('%Y%m%d_%H%M%S')
Out[8]: '20080910_213139'

In [11]: '%s.%3d' % (n.strftime('%Y%m%d_%H%M%S'), n.microsecond/1000)
Out[11]: '20080910_213139.937'

In [13]: n += timedelta(seconds=2, milliseconds=740)

In [14]: '%s.%3d' % (n.strftime('%Y%m%d_%H%M%S'), n.microsecond/1000)
Out[14]: '20080910_213142.677'

Kent

  

--
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet
            
          "If voting made any difference they wouldn't let us do it." 
                        -- Mark Twain
            
                    Web Page: <www.speckledwithstars.net/>
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to