Gets used by minutes(), hours() and days(), does the actual formatting work.
510494
protected function format($number, $oneWord, $typeWords)
    {
        $typeWord = $typeWords[$this->pluralization($number)];
        if ($number === 1) {
            $number = $oneWord;
        }
        return $this->pre_word . ' ' . $number . ' ' . $typeWord;
    }
724261
void formatMinutes(StringBuilder b, ZonedDateTime d, int width) {
    zeroPad2(b, d.getMinute(), width);
  }
401515
function formatDate(d, fmt, monthNames, dayNames) {

		if (typeof d.strftime == "function") {
			return d.strftime(fmt);
		}

		var leftPad = function(n, pad) {
			n = "" + n;
			pad = "" + (pad == null ? "0" : pad);
			return n.length == 1 ? pad + n : n;
		};

		var r = [];
		var escape = false;
		var hours = d.getHours();
		var isAM = hours < 12;

		if (monthNames == null) {
			monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
		}

		if (dayNames == null) {
			dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
		}

		var hours12;

		if (hours > 12) {
			hours12 = hours - 12;
		} else if (hours == 0) {
			hours12 = 12;
		} else {
			hours12 = hours;
		}

		for (var i = 0; i < fmt.length; ++i) {

			var c = fmt.charAt(i);

			if (escape) {
				switch (c) {
					case 'a': c = "" + dayNames[d.getDay()]; break;
					case 'b': c = "" + monthNames[d.getMonth()]; break;
					case 'd': c = leftPad(d.getDate()); break;
					case 'e': c = leftPad(d.getDate(), " "); break;
					case 'h':	// For back-compat with 0.7; remove in 1.0
					case 'H': c = leftPad(hours); break;
					case 'I': c = leftPad(hours12); break;
					case 'l': c = leftPad(hours12, " "); break;
					case 'm': c = leftPad(d.getMonth() + 1); break;
					case 'M': c = leftPad(d.getMinutes()); break;
					// quarters not in Open Group's strftime specification
					case 'q':
						c = "" + (Math.floor(d.getMonth() / 3) + 1); break;
					case 'S': c = leftPad(d.getSeconds()); break;
					case 'y': c = leftPad(d.getFullYear() % 100); break;
					case 'Y': c = "" + d.getFullYear(); break;
					case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
					case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
					case 'w': c = "" + d.getDay(); break;
				}
				r.push(c);
				escape = false;
			} else {
				if (c == "%") {
					escape = true;
				} else {
					r.push(c);
				}
			}
		}

		return r.join("");
	}
141403
function formatTime(time) {
      var hour;
      var minute;
      hour = Math.floor(time / 60);
      if (time % 60 === 0) {
        minute = 0;
      } else {
        minute = time % 60;
      }
      if (hour === 0) {
        return minute + '分钟';
      } else if (hour !== 0 && minute === 0) {
        return hour + '小时';
      } else {
        return hour + '小时' + minute + '分钟';
      }
    }
291549
function minutesToOffsetString(minutes) {
  var t = String(Math.abs(minutes / 60)).split('.');
  var H = pad(t[0]);
  var m = t[1] ? parseInt(t[1], 10) * 0.6 : 0;
  var sign = minutes < 0 ? '-' : '+';

  return '' + sign + H + ':' + pad(m);
}
167372
function fixFormat(format, _moment) {
    var i = 5;
    var replace = function (input) {
        return _moment.localeData().longDateFormat(input) || input;
    };
    while (i > 0 && localFormattingTokens.test(format)) {
        i -= 1;
        format = format.replace(localFormattingTokens, replace);
    }
    return format;
}
789278
function(format) {
      var dt, values = {}, 
      that = this,
      notSelected = false;

      //getting selected values    
      angular.forEach(this.map, function(v, k) {
        if(k === 'ampm') {
          return;
        }
        var def = k === 'day' ? 1 : 0;

        values[k] = that['$'+k] ? parseInt(that['$'+k].val(), 10) : def; 
        
        if(isNaN(values[k])) {
         notSelected = true;
         return false; 
       }
     });
      
      //if at least one visible combo not selected - return empty string
      if(notSelected) {
       return '';
     }

      //convert hours 12h --> 24h 
      if(this.$ampm) {
        //12:00 pm --> 12:00 (24-h format, midday), 12:00 am --> 00:00 (24-h format, midnight, start of day)
        if(values.hour === 12) {
          values.hour = this.$ampm.val() === 'am' ? 0 : 12;                    
        } else {
          values.hour = this.$ampm.val() === 'am' ? values.hour : values.hour+12;
        }
      }
      
      dt = moment([values.year, values.month, values.day, values.hour, values.minute, values.second]);
      
      //highlight invalid date
      this.highlight(dt);

      format = format === undefined ? this.options.format : format;
      if(format === null) {
       return dt.isValid() ? dt : null; 
     } else {
       return dt.isValid() ? dt.format(format) : ''; 
     }
   }
902358
function formatTime(lang, input) {
	var result = input;
	var matches;
	var localeTimeString;

	while ((matches = TIME_REGEX.exec(input)) != null) {

		var date = new Date(Date.parse(matches[1]));
		localeTimeString = date.toLocaleTimeString(lang,
			{
				hour: 'numeric',
				minute: '2-digit'
			});

		result = result.replace(matches[0], localeTimeString);
	};
	return result;
}
214643
function time_format(options) {
  if (_.isString(options.time)) {
    /* Translate the string we've been given into a format */
    switch(options.time) {
    case 'days':
    case 'Days':
      return "%d/%m";
    case 'hours':
    case 'Hours':
      return "%H:%M";
    default: /* Presume we've been given a gnuplot-readable time format string */
      return options.time;
    }
  } else { /* Just default to hours */
    return "%H:%M";
  }
}
895861
def format_items(x):
    """"""
    x = np.asarray(x)
    timedelta_format = 'datetime'
    if np.issubdtype(x.dtype, np.timedelta64):
        x = np.asarray(x, dtype='timedelta64[ns]')
        day_part = (x[~pd.isnull(x)]
                    .astype('timedelta64[D]')
                    .astype('timedelta64[ns]'))
        time_needed = x[~pd.isnull(x)] != day_part
        day_needed = day_part != np.timedelta64(0, 'ns')
        if np.logical_not(day_needed).all():
            timedelta_format = 'time'
        elif np.logical_not(time_needed).all():
            timedelta_format = 'date'

    formatted = [format_item(xi, timedelta_format) for xi in x]
    return formatted
1268861
function addDateFormatting(){
	
	Date.prototype.format = function(format) {
	    var returnStr = '';
	    var replace = Date.replaceChars;
	    for (var i = 0; i < format.length; i++) {       var curChar = format.charAt(i);         if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
	            returnStr += curChar;
	        }
	        else if (replace[curChar]) {
	            returnStr += replace[curChar].call(this);
	        } else if (curChar != "\\"){
	            returnStr += curChar;
	        }
	    }
	    return returnStr;
	};

	Date.replaceChars = {
	    shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
	    longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
	    shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
	    longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],

	    // Day
	    d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
	    D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
	    j: function() { return this.getDate(); },
	    l: function() { return Date.replaceChars.longDays[this.getDay()]; },
	    N: function() { return this.getDay() + 1; },
	    S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
	    w: function() { return this.getDay(); },
	    z: function() { var d = new Date(this.getFullYear(),0,1); return Math.ceil((this - d) / 86400000); }, // Fixed now
	    // Week
	    W: function() { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); }, // Fixed now
	    // Month
	    F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
	    m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
	    M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
	    n: function() { return this.getMonth() + 1; },
	    t: function() { var d = new Date(); return new Date(d.getFullYear(), d.getMonth(), 0).getDate() }, // Fixed now, gets #days of date
	    // Year
	    L: function() { var year = this.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); },   // Fixed now
	    o: function() { var d  = new Date(this.valueOf());  d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now
	    Y: function() { return this.getFullYear(); },
	    y: function() { return ('' + this.getFullYear()).substr(2); },
	    // Time
	    a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
	    A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
	    B: function() { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); }, // Fixed now
	    g: function() { return this.getHours() % 12 || 12; },
	    G: function() { return this.getHours(); },
	    h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
	    H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
	    i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
	    s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
	    u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ?
	'0' : '')) + m; },
	    // Timezone
	    e: function() { return "Not Yet Supported"; },
	    I: function() {
	        var DST = null;
	            for (var i = 0; i < 12; ++i) {
	                    var d = new Date(this.getFullYear(), i, 1);
	                    var offset = d.getTimezoneOffset();

	                    if (DST === null) DST = offset;
	                    else if (offset < DST) { DST = offset; break; }                     else if (offset > DST) break;
	            }
	            return (this.getTimezoneOffset() == DST) | 0;
	        },
	    O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
	    P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; }, // Fixed now
	    T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
	    Z: function() { return -this.getTimezoneOffset() * 60; },
	    // Full Date/Time
	    c: function() { return this.format("Y-m-d\\TH:i:sP"); }, // Fixed now
	    r: function() { return this.toString(); },
	    U: function() { return this.getTime() / 1000; }
	};
}
272197
def hour_of_day(*hours)
      hours.flatten.each do |hour|
        unless hour.is_a?(Integer)
          raise ArgumentError, "expecting Integer value for hour, got #{hour.inspect}"
        end

        verify_alignment(hour, :hour, :hour_of_day) { |error| raise error }

        validations_for(:hour_of_day) << Validation.new(hour)
      end
      clobber_base_validations(:hour)
      self
    end
799149
protected static void formatTimeDifference(long diff, StringBuilder b){
    //--Get Values
    int mili = (int) diff % 1000;
    long rest = diff / 1000;
    int sec = (int) rest % 60;
    rest = rest / 60;
    int min = (int) rest % 60;
    rest = rest / 60;
    int hr = (int) rest % 24;
    rest = rest / 24;
    int day = (int) rest;
    //--Make String
    if(day > 0) b.append(day).append(day > 1 ? " days, " : " day, ");
    if(hr > 0) b.append(hr).append(hr > 1 ? " hours, " : " hour, ");
    if(min > 0) {
      if(min < 10){ b.append("0"); }
      b.append(min).append(":");
    }
    if(min > 0 && sec < 10){ b.append("0"); }
    b.append(sec).append(".").append(mili);
    if(min > 0) b.append(" minutes");
    else b.append(" seconds");
  }
819376
public String format(Duration duration) {
    Long durationInMinutes = duration.toMinutes();
    if (durationInMinutes == 0) {
      return "0";
    }
    boolean isNegative = durationInMinutes < 0;
    Long absDuration = Math.abs(durationInMinutes);

    int days = ((Double) ((double) absDuration / HOURS_IN_DAY / 60)).intValue();
    Long remainingDuration = absDuration - (days * HOURS_IN_DAY * 60);
    int hours = ((Double) (remainingDuration.doubleValue() / 60)).intValue();
    remainingDuration = remainingDuration - (hours * 60);
    int minutes = remainingDuration.intValue();

    return format(days, hours, minutes, isNegative);
  }
1199978
private TimeUnit getFormat(int format)
   {
      TimeUnit result;
      if (format == 0xFFFF)
      {
         result = TimeUnit.HOURS;
      }
      else
      {
         result = MPPUtility.getWorkTimeUnits(format);
      }
      return result;
   }
666369
function(numbers) {
    var stepsize = stepSize(numbers);
    if(!numbers) {
      return { beginning: 'minute', text: '' };
    }

    var minutes = { beginning: '', text: '' };
    if( isOnTheHour( numbers ) ) {
      minutes.text = 'hour, on the hour';
    } else if( isEveryOther( stepsize, numbers ) ) {
      minutes.beginning = 'other minute';
    } else if( isStepValue( stepsize, numbers ) ) {
      minutes.text = stepsize + ' minutes';
    } else if( isTwicePerHour( stepsize, numbers ) ) {
      minutes.text = 'first and 30th minute';
    } else {
      minutes.text = numberList(numbers) + ' minute';
    }
    return minutes;
  }
666243
def format_timedelta(t, timedelta_format=None):
    """"""
    timedelta_str = str(pd.Timedelta(t))
    try:
        days_str, time_str = timedelta_str.split(' days ')
    except ValueError:
        # catch NaT and others that don't split nicely
        return timedelta_str
    else:
        if timedelta_format == 'date':
            return days_str + ' days'
        elif timedelta_format == 'time':
            return time_str
        else:
            return timedelta_str