code: def dateTimeToString(dateTime, convertToUTC=False):
      
      if dateTime.tzinfo and convertToUTC:
          dateTime = dateTime.astimezone(utc)
  
      datestr = "{}{}{}T{}{}{}".format(
          numToDigits(dateTime.year, 4),
          numToDigits(dateTime.month, 2),
          numToDigits(dateTime.day, 2),
          numToDigits(dateTime.hour, 2),
          numToDigits(dateTime.minute, 2),
          numToDigits(dateTime.second, 2),
      )
      if tzinfo_eq(dateTime.tzinfo, utc):
          datestr += "Z"
      return datestr
docs: Ignore tzinfo unless convertToUTC.  Output string.