If the cell is a date, format it to MM/DD/YYYY, stripping time.
7565
def format_date(a_cell)
    isdate = true if(nil != (dt = a_cell.match(@date_RE)))
    isdate = true if(isdate || (nil != (dt = a_cell.match(@date_with_dashes_RE))) )
    isdate = true if(isdate || (nil != (dt = a_cell.match(@date_with_time_RE))) )
    if isdate
      begin
        mod_dt = DateTime.parse(a_cell)
        cary = "#{mod_dt.month}/#{mod_dt.day}/#{mod_dt.year}"
        if(true == verbose?)
          puts ""
          puts "*** Converted date to #{cary} ***"
          puts ""
        end
        a_cell = cary
      rescue ArgumentError => e
        # Either this is not a date, or the date format is unrecognized,
        # nothing to see here, moving on.
      end
    end
    a_cell
  end
1181624
def clean_cell(self, cell, cell_type):
        
        try:
            # Get rid of non-ASCII characters
            cell = cell.encode('ascii', 'ignore').decode()
            if cell_type == 'D':
                cell = datetime.strptime(cell, '%Y%m%d')
            elif cell_type == 'I':
                cell = int(cell)
            elif cell_type == 'N':
                cell = Decimal(cell)
            else:
                cell = cell.upper()

                if len(cell) > 50:
                    cell = cell[0:50]

                if not cell or cell in NULL_TERMS:
                    cell = None

        except:
            cell = None

        return cell
1353052
function format(date, month, time) {
  return date.getFullYear() +
         zeroFill(date.getMonth() + 1) +
         (month ? zeroFill(date.getDate()) : '') +
         (time ?  'T' + zeroFill(date.getHours()) + zeroFill(date.getMinutes()) +
            zeroFill(date.getSeconds()) + 'Z' : '');
}
111990
def date_clean(date, dashboard_style=False):
  
  if dashboard_style:
    dt = str(date)
    out = dt[4:6] + '/' + dt[6:] + '/' + dt[:4]
  else:
    dt = str(date)
    out = dt[:4] + '-' + dt[4:6] + '-' + dt[6:]
  return out
483230
def convert_date(date):
    """"""
    date = convert_month(date, shorten=False)
    clean_string = convert_string(date)
    return datetime.strptime(clean_string, DATE_FMT.replace('-',''))
1002369
def format_dates! format=nil
      each do |row|
        row.each_with_index do |value, idx|
          unless row.formats[idx] || row.format(idx).date_or_time?
            numfmt = case value
                     when DateTime, Time
                       format || client('DD.MM.YYYY hh:mm:ss', 'UTF-8')
                     when Date
                       format || client('DD.MM.YYYY', 'UTF-8')
                     end
            case numfmt
            when Format
              row.set_format idx, numfmt
            when String
              fmt = row.format(idx).dup
              fmt.number_format = numfmt
              row.set_format idx, fmt
            end
          end
        end
      end
    end
647919
function format(ms) {
  if (ms == d) return Math.round(ms / d) + ' day';
  if (ms > d) return Math.round(ms / d) + ' days';
  if (ms == h) return Math.round(ms / h) + ' hour';
  if (ms > h) return Math.round(ms / h) + ' hours';
  if (ms == m) return Math.round(ms / m) + ' minute';
  if (ms > m) return Math.round(ms / m) + ' minutes';
  if (ms == s) return Math.round(ms / s) + ' second';
  if (ms > s) return Math.round(ms / s) + ' seconds';
  return ms + ' ms';
}
163629
def to_datetime(plain_date, hours=0, minutes=0, seconds=0, ms=0):
    """"""
    # don't mess with datetimes
    if isinstance(plain_date, datetime.datetime):
        return plain_date
    return datetime.datetime(
        plain_date.year,
        plain_date.month,
        plain_date.day,
        hours,
        minutes,
        seconds,
        ms,
    )
1129555
def date_to_datetime(x):
    """"""
    if not isinstance(x, datetime) and isinstance(x, date):
        return datetime.combine(x, time())
    return x
1359120
def formatTime (self, record, datefmt=None):
        """"""
        if datefmt is None:
            datefmt = '%Y-%m-%d %H:%M:%S'

        ct = self.converter(record.created)
        t  = time.strftime(datefmt, ct)
        s  = '%s.%03d' % (t, record.msecs)

        return s
436962
def match_date(self, value, strict=False):
        """"""
        value = stringify(value)
        try:
            parse(value)
        except Exception:
            self.shout('Value %r is not a valid date', strict, value)
86347
function datetime(date, format) {
    if (format === undefined) {
        //datetime() => now timestamp
        if (date === undefined) {
            return Math.floor(Date.now() / 1000);
        } else if (lodash.isString(date)) { //datetime('2017-01-01') => timestamp
            date = date || new Date();
            return Math.floor(new Date(date).getTime() / 1000);
        }
        return NaN;
    } else {
        format = format || 'yyyy-mm-dd hh:mi:ss';
        let fn = function (d, f) {
            let Week = ['日', '一', '二', '三', '四', '五', '六'];
            f = f.replace(/yyyy|YYYY/, d.getFullYear());
            f = f.replace(/yy|YY/, d.getYear() % 100 > 9 ? (d.getYear() % 100).toString() : '0' + d.getYear() % 100);
            f = f.replace(/mi|MI/, d.getMinutes() > 9 ? d.getMinutes().toString() : '0' + d.getMinutes());
            f = f.replace(/mm|MM/, d.getMonth() + 1 > 9 ? (d.getMonth() + 1).toString() : '0' + (d.getMonth() + 1));
            f = f.replace(/m|M/g, d.getMonth() + 1);
            f = f.replace(/w|W/g, Week[d.getDay()]);
            f = f.replace(/dd|DD/, d.getDate() > 9 ? d.getDate().toString() : '0' + d.getDate());
            f = f.replace(/d|D/g, d.getDate());
            f = f.replace(/hh|HH/, d.getHours() > 9 ? d.getHours().toString() : '0' + d.getHours());
            f = f.replace(/h|H/g, d.getHours());
            f = f.replace(/ss|SS/, d.getSeconds() > 9 ? d.getSeconds().toString() : '0' + d.getSeconds());
            return f;
        };
        if (date && lodash.isNumber(date)) {
            let newDate = new Date();
            newDate.setTime(date * 1000);
            return fn(newDate, format);
        }
        if (date && lodash.isString(date)) {
            return fn(new Date(Date.parse(date)), format);
        }
        return fn(new Date(), format);
    }
}
1293722
def str2dt(s):
    """"""
    return datetime.datetime.strptime(s, _FMTS if s.count(":") == 2 else _FMT if s.count(":") == 1 else _FMT0)
37422
def _cell_to_python(cell):
    """"""
    data_type, value = cell.data_type, cell.value

    if type(cell) is EmptyCell:
        return None
    elif data_type == "f" and value == "=TRUE()":
        return True
    elif data_type == "f" and value == "=FALSE()":
        return False

    elif cell.number_format.lower() == "yyyy-mm-dd":
        return str(value).split(" 00:00:00")[0]
    elif cell.number_format.lower() == "yyyy-mm-dd hh:mm:ss":
        return str(value).split(".")[0]

    elif cell.number_format.endswith("%") and isinstance(value, Number):
        value = Decimal(str(value))
        return "{:%}".format(value)

    elif value is None:
        return ""
    else:
        return value
807450
private String formatTime(Date value)
   {
      return (value == null ? null : m_formats.getTimeFormat().format(value));
   }
1040608
function(format, date) {
		var self = this,
			output, d, dw, m, y, h, g, i, s;
		
		if (! date) {
			date = new Date();
		}
		
		h  = date[self.getHours]();
		g  = h > 12 ? h - 12 : h;
		i  = date[self.getMinutes]();
		s  = date[self.getSeconds]();
		d  = date[self.getDate]();
		dw = date[self.getDay]();
		m  = date[self.getMonth]() + 1;
		y  = date[self.getFullYear]();
		
		output = format.replace(/[a-z]/gi, function(val) {
			switch (val) {
				case 'd': return d > 9 ? d : '0'+d;
				case 'j': return d;
				case 'D': return self.i18n(self.i18.daysShort[dw]);
				case 'l': return self.i18n(self.i18.days[dw]);
				case 'm': return m > 9 ? m : '0'+m;
				case 'n': return m;
				case 'M': return self.i18n(self.i18.monthsShort[m-1]);
				case 'F': return self.i18n(self.i18.months[m-1]);
				case 'Y': return y;
				case 'y': return (''+y).substr(2);
				case 'H': return h > 9 ? h : '0'+h;
				case 'G': return h;
				case 'g': return g;
				case 'h': return g > 9 ? g : '0'+g;
				case 'a': return h >= 12 ? 'pm' : 'am';
				case 'A': return h >= 12 ? 'PM' : 'AM';
				case 'i': return i > 9 ? i : '0'+i;
				case 's': return s > 9 ? s : '0'+s;
			}
			return val;
		});
		
		return output;
	}
249497
def normalize_date_format(date_str, default_time="00:00:00"):
    """"""
    ret_code, ret_data = check_date_str_format(date_str, default_time)
    if ret_code != RET_OK:
        return ret_code, ret_data

    return RET_OK, ret_data.strftime("%Y-%m-%d %H:%M:%S")