[FRPythoneers] Data type conversion

J. Wayde Allen wallen at lug.boulder.co.us
Wed May 2 09:50:51 MDT 2001

OK, new problem for the day.  I've succeeded in pulling an ASCII string
representing a time of day out of my data file, and have applied a
numerical offset to this.

        #Compute the sample time
         hours = string.atoi(timestamp[0:2])
         minutes = string.atoi(timestamp[2:4])
         seconds = string.atof(timestamp[4:6])
         offset = offset - 2
         seconds = seconds + offset
         if seconds < 0:
            minutes = minutes - 1
            seconds = seconds + 60
         if minutes < 0:
            hours = hours - 1
            minutes = minutes + 60
         if hours < 0:             #Previous day
            hours = hours + 24

At this time I'd like to put the pieces back together again in the same
hhmmss format.  I was thinking something like:

         sampletime = string.join((hours,minutes,seconds),'')

The problem is that my hours, minutes, and seconds are now of type integer
and float.  So how do I convert them back to string form?

- Wayde
  (wallen at lug.boulder.co.us)

More information about the FRPythoneers mailing list