technical time formats (e.g. the time part of ISO 8601), take some options and this commonizes their handling
974907
function toTechTimeFormat(
  dt,
  {
    suppressSeconds = false,
    suppressMilliseconds = false,
    includeOffset,
    includeZone = false,
    spaceZone = false
  }
) {
  let fmt = "HH:mm";

  if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
    fmt += ":ss";
    if (!suppressMilliseconds || dt.millisecond !== 0) {
      fmt += ".SSS";
    }
  }

  if ((includeZone || includeOffset) && spaceZone) {
    fmt += " ";
  }

  if (includeZone) {
    fmt += "z";
  } else if (includeOffset) {
    fmt += "ZZ";
  }

  return toTechFormat(dt, fmt);
}
130058
def as_iso8601(self):
        
        if self.__time is None:
            return None

        return "%s:%s:%s0Z" % (self.__time[:2], self.__time[2:4], self.__time[4:])
570366
def convert_time(time):
    """"""
    split_time = time.split()
    try:
        # Get rid of period in a.m./p.m.
        am_pm = split_time[1].replace('.', '')
        time_str = '{0} {1}'.format(split_time[0], am_pm)
    except IndexError:
        return time
    try:
        time_obj = datetime.strptime(time_str, '%I:%M %p')
    except ValueError:
        time_obj = datetime.strptime(time_str, '%I %p')

    return time_obj.strftime('%H:%M %p')
1290172
function parseISO(config) {
        var i, l,
            string = config._i,
            match = isoRegex.exec(string);

        if (match) {
            config._pf.iso = true;
            for (i = 0, l = isoDates.length; i < l; i++) {
                if (isoDates[i][1].exec(string)) {
                    // match[5] should be "T" or undefined
                    config._f = isoDates[i][0] + (match[6] || " ");
                    break;
                }
            }
            for (i = 0, l = isoTimes.length; i < l; i++) {
                if (isoTimes[i][1].exec(string)) {
                    config._f += isoTimes[i][0];
                    break;
                }
            }
            if (string.match(parseTokenTimezone)) {
                config._f += "Z";
            }
            makeDateFromStringAndFormat(config);
        } else {
            config._isValid = false;
        }
    }
1024740
function (timeFormat) {
		var tf = timeFormat.replace(/'.*?'/g, '').toLowerCase(), // removes literals
			isIn = function (f, t) { // does the format contain the token?
					return f.indexOf(t) !== -1 ? true : false;
				};
		return {
				hour: isIn(tf, 'h'),
				minute: isIn(tf, 'm'),
				second: isIn(tf, 's'),
				millisec: isIn(tf, 'l'),
				microsec: isIn(tf, 'c'),
				timezone: isIn(tf, 'z'),
				ampm: isIn(tf, 't') && isIn(timeFormat, 'h'),
				iso8601: isIn(timeFormat, 'Z')
			};
	}
946762
def iso_format_time(time)
      return time unless time.is_a? Time or time.is_a? Date
      time = time.getutc if time.is_a? Time
      time = time.new_offset(0) if time.is_a? DateTime
      time.strftime('%Y-%m-%dT%H:%M:%SZ')
    end
6065
function( timeString, format ) {

			this.setFormat(format);
			this.clearTime();
			var parts = [];

			// discover date separtor for auto profile // default is ':'
			if(timeString.indexOf(':') === -1) {
				this.autoProfile.tsep = '';
			}

			// finds timezone HH:MM:SS and HHMMSS  ie 13:30:45, 133045 and 13:30:45.0135
			parts = timeString.match( /(\d\d)?:?(\d\d)?:?(\d\d)?.?([0-9]+)?/ );
			if(parts[1]) {
				this.tH = parts[1];
			}
			if(parts[2]) {
				this.tM = parts[2];
			}
			if(parts[3]) {
				this.tS = parts[3];
			}
			if(parts[4]) {
				this.tD = parts[4];
			}
			return this.toTimeString(this.format);
		}
206981
def clean_time(self, time):
        
        if isinstance(time, int):
            time = datetime.utcfromtimestamp(time)
        elif isinstance(time, str):
            time = parser.parse(time)

        return time
1347551
def normalize_time_to_netsuite_date(unix_timestamp)
      # convert to date to eliminate hr/min/sec
      time = Time.at(unix_timestamp).
        utc.
        to_date.
        to_datetime

      # tzinfo allows us to determine the dst status of the time being passed in
      # NetSuite requires that the time be passed to the API with the PDT TZ offset
      # of the time passed in (i.e. not the current TZ offset of PDT)

      if defined?(TZInfo)
        # if no version is defined, less than 2.0
        # https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md#added
        if !defined?(TZInfo::VERSION)
          # https://stackoverflow.com/questions/2927111/ruby-get-time-in-given-timezone
          offset = TZInfo::Timezone.get("America/Los_Angeles").period_for_utc(time).utc_total_offset_rational
          time = time.new_offset(offset)
        else
          time = TZInfo::Timezone.get("America/Los_Angeles").utc_to_local(time)
          offset = time.offset
        end
      else
        # if tzinfo is not installed, let's give it our best guess: -7
        offset = Rational(-7, 24)
        time = time.new_offset("-07:00")
      end

      time = (time + (offset * -1))
      time.iso8601
    end
890246
def _resolve_time(value):
  '''
  
  '''
  if value is None or isinstance(value,(int,long)):
    return value

  if NUMBER_TIME.match(value):
    return long(value)

  simple = SIMPLE_TIME.match(value)
  if SIMPLE_TIME.match(value):
    multiplier = long( simple.groups()[0] )
    constant = SIMPLE_TIMES[ simple.groups()[1] ]
    return multiplier * constant

  if value in GREGORIAN_TIMES:
    return value

  raise ValueError('Unsupported time format %s'%value)
893185
def _convert_ftp_time_to_iso(ftp_time):
        
        date_time = datetime(
            int(ftp_time[:4]), int(ftp_time[4:6]), int(ftp_time[6:8]),
            int(ftp_time[8:10]), int(ftp_time[10:12]), int(ftp_time[12:14]))
        return date_time
751708
def clean_time(sltime, in_format='%Y-%m-%dT%H:%M:%S%z', out_format='%Y-%m-%d %H:%M'):
    
    try:
        clean = datetime.datetime.strptime(sltime, in_format)
        return clean.strftime(out_format)
    # The %z option only exists with py3.6+
    except ValueError:
        return sltime
961482
function extractIso8601TimePieces(value) {
    var timePieces = /^(\d{2}):(\d{2})(?:\:(\d{2}))?(?:\.(\d{1,3}))?$/.exec(value);
    if (timePieces === null) {
      return null;
    }

    var hour = timePieces[1] ? parseInt(timePieces[1], 10) : 0;
    var minute = timePieces[2] ? parseInt(timePieces[2], 10) : 0;
    var second = timePieces[3] ? parseInt(timePieces[3], 10) : 0;

    // The millisecond component has a variable length; normalize the length by padding it with zeros
    var millisecond = timePieces[4] ? parseInt(utils.padRight(timePieces[4], 3, '0'), 10) : 0;

    return [ hour, minute, second, millisecond ];
  }
1211483
def parse_isotime(timestr):
    """"""
    try:
        return iso8601.parse_date(timestr)
    except iso8601.ParseError as e:
        raise ValueError(six.text_type(e))
    except TypeError as e:
        raise ValueError(six.text_type(e))
532987
function normaliseDateTime(value) {
    if (_.isDate(value)) {
        return value;
    }

    // 'Shamnic' style heuristics
    var denormDate = /(\d{1,2})\/(\d{1,2})\/(\d{4})(?:\s+(\d{1,2})\:(\d{1,2})\s+(AM|PM)){0,1}/i;
    var partNormDate = /(\d{4})-(\d{1,2})-(\d{1,2})(?:\s+(\d{1,2})\:(\d{1,2})\s+(AM|PM)){0,1}/i;

    var partNorm = partNormDate.exec(value);

    var denorm = denormDate.exec(value);
    var align = function(value) {
        if (value && value.length === 1) {
            return '0' + value;
        } else {
            return value;
        }
    };

    if (denorm && !denorm[4]) { //Denormalized date only '31/12/2001'
        //Switch to yyyy-mm-dd
        return denorm[3] + '-' + align(denorm[1]) + '-' + align(denorm[2]);
    }

    if (denorm) { //Denormalized date and time '31/12/2001 3:30 PM'
        //Switch to yyyy-mm-ddZHH:mm
        return denorm[3] + '-' + align(denorm[1]) + '-' + align(denorm[2]) + 'Z' + ((denorm[6] === 'AM') ? denorm[4] : ((partNorm[4] === '12') ? '12' : (parseInt(partNorm[4]) + 12).toString())) + ':' + denorm[5];
    }

    if (partNorm && !partNorm[4]) { //Normalized date '2001-12-31'
        return value; // Do nothing
    }

    if (partNorm) { // Normalized date and denorm time '2001-12-31 3:30 PM'
        return partNorm[1] + '-' + align(partNorm[2]) + '-' + align(partNorm[3]) + 'T' + ((partNorm[6] === 'AM') ? partNorm[4] : ((partNorm[4] === '12') ? '12' : (parseInt(partNorm[4]) + 12).toString())) + ':' + partNorm[5] + ':00';
    }

    //WTF? Passthrough.
    return value;
}
598326
def QA_util_to_datetime(time):
    
    if len(str(time)) == 10:
        _time = '{} 00:00:00'.format(time)
    elif len(str(time)) == 19:
        _time = str(time)
    else:
        QA_util_log_info('WRONG DATETIME FORMAT {}'.format(time))
    return datetime.datetime.strptime(_time, '%Y-%m-%d %H:%M:%S')
944862
def get_iso_time(date_part, time_part):
    """
    str_date = datetime.datetime.strptime(
        date_part, '%m/%d/%Y').strftime('%Y-%m-%d')
    str_time = datetime.datetime.strptime(
        time_part, '%I:%M %p').strftime('%H:%M:%S')

    return str_date + "T" + str_time + "-7:00"