convert Word date/time picture (msformat) into a strftime format string
429600
def strftime_string(C, msformat):
        ""
        s = msformat
        s = re.sub(r"%", "%%", s)                   # percent sign
        s = re.sub(r"(?<!%)\b(y(?:yyy)?)\b", "%Y", s)   # 4-digit year
        s = re.sub(r"(?<!%)\b(yy)\b", "%y", s)     # 2-digit year
        s = re.sub(r"(?<!%)\b(MMMM)\b", "%B", s)   # full month
        s = re.sub(r"(?<!%)\b(MMM)\b", "%b", s)    # abbrev. month
        s = re.sub(r"(?<!%)\b(MM)\b", "%m", s)     # 2-digit month
        s = re.sub(r"(?<!%)\b(dd?)\b", "%d", s)    # day
        s = re.sub(r"(?<!%)\b(hh?)\b", "%I", s)    # 12-hr hour
        s = re.sub(r"(?<!%)\b(HH?)\b", "%H", s)    # 24-hr hour
        s = re.sub(r"(?<!%)\b(mm?)\b", "%M", s)    # minute
        s = re.sub(r"(?<!%)\b(ss?)\b", "%S", s)    # second
        s = re.sub(r"(?<!%)\b(am/pm)\b", "%p", s)  # 2-digit year
        return s
163215
def dt2str(dt, flagSeconds=True):
    """"""
    if isinstance(dt, str):
        return dt
    return dt.strftime(_FMTS if flagSeconds else _FMT)
1087595
function fmtXyzDate(fmtStr, time, offset) {
      var date = dateBase(time);
      if (!date.getTime()) return '';
      var ms = date.getUTCMilliseconds()
        , tm = timestamp(fmtUtcDate('yyyy/MM/dd hh:mm:ss', time)) + ms + (!+offset ? 0 : +offset);
      return fmtDate(fmtStr, tm);
    }
1142915
def _x_format(self):
        """"""

        def timedelta_to_str(x):
            td = timedelta(seconds=x)
            return self.x_value_formatter(td)

        return timedelta_to_str
524952
public static String formatDateTime(long ms) {
    return formatDateTime(OffsetDateTime.ofInstant(Instant.ofEpochMilli(ms), ZoneId.systemDefault()));
  }
1314237
def formatdt(date: datetime.date, include_time: bool = True) -> str:
    
    if include_time:
        return date.strftime("%Y-%m-%dT%H:%M")
    else:
        return date.strftime("%Y-%m-%d")
299362
function datePrettyFormat(ms, opts) {
  if (typeof ms !== 'number') {
    throw new TypeError('Expected a number');
  }

  if (ms < 1000) {
    return Math.ceil(ms) + 'ms';
  }

  opts = opts || {};

  var secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
  var ret = [];
  var parsed = formatDate(ms);

  ret = add(ret, parsed.years, 'y');
  ret = add(ret, parsed.days, 'd');
  ret = add(ret, parsed.hours, 'h');
  ret = add(ret, parsed.minutes, 'm');

  if (opts.compact) {
    ret = add(ret, parsed.seconds, 's');
    return '~' + ret[0];
  }

  ret = add(ret, (ms / 1000 % 60).toFixed(secDecimalDigits).replace(/\.0$/, ''), 's');

  return ret.join(' ');
}
203629
def _convert_date_time_string(dt_string):
    '''
    
    '''
    dt_string = dt_string.split('.')[0]
    dt_obj = datetime.strptime(dt_string, '%Y%m%d%H%M%S')
    return dt_obj.strftime('%Y-%m-%d %H:%M:%S')
252075
def ms_to_timestamp(ms):
    """'"""
    # XXX throw on overflow/underflow?
    if ms < 0: ms = 0
    if ms > MAX_REPRESENTABLE_TIME: ms = MAX_REPRESENTABLE_TIME
    h, m, s, ms = ms_to_times(ms)
    return "%01d:%02d:%02d.%02d" % (h, m, s, ms//10)
792106
def formatTime(self, record, datefmt=None):  # noqa
        
        if datefmt:
            s = datetime.datetime.now().strftime(datefmt)
        else:
            t = datetime.datetime.now().strftime(self.default_time_format)
            s = self.default_msec_format % (t, record.msecs)
        return s
685107
def _tzstr(self, sep=":"):
        """"""
        off = self.utcoffset()
        if off is not None:
            if off.days < 0:
                sign = "-"
                off = -off
            else:
                sign = "+"
            hh, mm = divmod(off, timedelta(hours=1))
            assert not mm % timedelta(minutes=1), "whole minute"
            mm //= timedelta(minutes=1)
            assert 0 <= hh < 24
            off = "%s%02d%s%02d" % (sign, hh, sep, mm)
        return off
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";
  }
}
417352
def std_datetimestr(self, datetimestr):
        
        return datetime.strftime(
                self.str2datetime(datetimestr), self.std_datetimeformat)
644164
private FileTime convertDateToFileTime(String strDate) {
        FileTime time = null;
        if (null != strDate) {
            Date date = null;
            try {
                date = DateUtil.convertToDate(strDate,
                                              DateUtil.DateFormat.LONG_FORMAT);
            } catch (ParseException e) {
                date = null;
            }

            if (null != date) {
                time = FileTime.fromMillis(date.getTime());
            }
        }
        return time;
    }
297615
def stringToDateTime(s, tzinfo=None):
    """"""
    try:
        year = int(s[0:4])
        month = int(s[4:6])
        day = int(s[6:8])
        hour = int(s[9:11])
        minute = int(s[11:13])
        second = int(s[13:15])
        if len(s) > 15:
            if s[15] == 'Z':
                tzinfo = utc
    except:
        raise ParseError("'%s' is not a valid DATE-TIME" % s)
    year = year and year or 2000
    return datetime.datetime(year, month, day, hour, minute, second, 0, tzinfo)
943282
def strptime(cls, date_string, format):
        ''
        import _strptime
        return _strptime._strptime_datetime(cls, date_string, format)
398547
def _str_to_time(self, str_value):
        """"""
        match = self.rx_time.match(str_value.upper())
        if not match:
            return None
        try:
            gd = match.groupdict()
            hour = int(gd['hour'])
            minute = int(gd['minute'])
            second = int(gd['second'] or 0)
            if gd['tt'] == 'PM':
                hour += 12
            return datetime.time(hour, minute, second)
        except (ValueError, TypeError):
            return None