Is there a command to display number of seconds as hrs:min:seconds?

Bob Sneidar bobsneidar at iotecdigital.com
Thu Oct 17 10:47:32 EDT 2019


I call it sqltime because it has to be formatted as hh:mm:ss. 

function formatTime theTime, theFormat
   /*
   accepts any valid time and returns the form of the time specified in the second parameter.
   The valid formats are:
   sql time: hh:mm:ss (Note: combining sql date from the formatDate() function with the
   sql time will produce a valid SQL date time type). 
   short time: LC short time format
   abbreviated time: LC abbr time format (same as short time)
   long time: LC long time format
   seconds: the number of seconds since the prior midnight
   military: the military time 00:00 - 23:59
   */
   if theTime is empty then return empty
   
   set the numberformat to "00"
   switch theFormat
      case "sql time"
         convert theTime to dateitems
         put (item 4 of theTime +0) & ":" & \
               (item 5 of theTime +0) & ":" & \
               (item 6 of theTime +0) into theTime
         break
      case "short time"
         convert theTime to short time
         break
      case "abbreviated time"
         convert theTime to abbreviated time
         break
      case "long time"
         convert theTime to long time
         break
      case "seconds"
         convert theTime to seconds
         break
      case "military"
         set the itemdelimiter to ":"
         
         if theTime contains "PM" then
            add 12 to item 1 of theTime
         end if
         
         put word 1 of item 2 of theTime into item 2 of theTime
         break
   end switch
   
   return theTime
end formatTime


> On Oct 16, 2019, at 17:23 , Bill Vlahos via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> I’m writing a countdown timer application and want to display the remaining time not as the number of seconds but in the format of HR:MIN:SEC left.
> 
> For example 75 seconds would display as “0:1:15”.
> 130 seconds would display as “0:2:10”.
> 
> I know how to do the math to figure it out but I’m wondering if there is a built in function to do this.
> 
> Convert wants to deal with actual time so I would get something like “0:1:15 PM”.
> 
> Thanks,
> Bill Vlahos
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list