code: def seconds_to_str_fromatter(_format):
      
      # check directives are correct 
      
      if _format == "%S":
          def _fromatter(seconds):
              return "{:.2f}".format(seconds)
      
      elif _format == "%I":
          def _fromatter(seconds):
              return "{0}".format(int(seconds * 1000))
      
      else:
          _format = _format.replace("%h", "{hrs:02d}")
          _format = _format.replace("%m", "{mins:02d}")
          _format = _format.replace("%s", "{secs:02d}")
          _format = _format.replace("%i", "{millis:03d}")
          
          try:
              i = _format.index("%")
              raise TimeFormatError("Unknow time format directive '{0}'".format(_format[i:i+2]))
          except ValueError:
              pass
          
          def _fromatter(seconds):
              millis = int(seconds * 1000)
              hrs, millis = divmod(millis, 3600000)
              mins, millis = divmod(millis, 60000)
              secs, millis = divmod(millis, 1000)
              return _format.format(hrs=hrs, mins=mins, secs=secs, millis=millis)
      
      return _fromatter
docs: Accepted format directives: %i %s %m %h