Returns a time literal if value is likely coercible to a time

    Parameters
    ----------
    value : time value as string

    Returns
    --------
    result : TimeScalar
17495
def time(value):
    
    if isinstance(value, str):
        value = to_time(value)
    return literal(value, type=dt.time)
1310816
def now (time_t = None, slug = False):
  '''
  '''
  if not time_t:
    time_t = time ()
  time_s = strftime (
    DEFAULT_SLUGFORMAT if slug else DEFAULT_TIMEFORMAT,
    gmtime (time_t))
  return (int (time_t), time_s)
678132
def time_str (time_t, slug = False):
  '''
  '''
  return datetime.fromtimestamp (int (time_t)).strftime (
    DEFAULT_SLUGFORMAT if slug else DEFAULT_TIMEFORMAT)
787545
def time_from_number(self, value):
        
        if not isinstance(value, numbers.Real):
            return None
        delta = datetime.timedelta(days=value)
        minutes, second = divmod(delta.seconds, 60)
        hour, minute = divmod(minutes, 60)
        return datetime.time(hour, minute, second)
821027
def parse_temporal(value)
      return Date.current if value =~ /\btoday\b/i
      return 1.day.ago.to_date if value =~ /\byesterday\b/i
      return 1.day.from_now.to_date if value =~ /\btomorrow\b/i
      return (eval($1.strip.gsub(/\s+/,'.').downcase)).to_datetime if value =~ /\A\s*(\d+\s+\b(?:hours?|minutes?)\b\s+\bago)\b\s*\z/i
      return (eval($1.strip.gsub(/\s+/,'.').downcase)).to_date     if value =~ /\A\s*(\d+\s+\b(?:days?|weeks?|months?|years?)\b\s+\bago)\b\s*\z/i
      return (eval($1.strip.gsub(/from\s+now/i,'from_now').gsub(/\s+/,'.').downcase)).to_datetime if value =~ /\A\s*(\d+\s+\b(?:hours?|minutes?)\b\s+\bfrom\s+now)\b\s*\z/i
      return (eval($1.strip.gsub(/from\s+now/i,'from_now').gsub(/\s+/,'.').downcase)).to_date     if value =~ /\A\s*(\d+\s+\b(?:days?|weeks?|months?|years?)\b\s+\bfrom\s+now)\b\s*\z/i
      DateTime.parse(value, true) rescue nil
    end
218056
def to_string(value, ctx):
    
    if isinstance(value, bool):
        return "TRUE" if value else "FALSE"
    elif isinstance(value, int):
        return str(value)
    elif isinstance(value, Decimal):
        return format_decimal(value)
    elif isinstance(value, str):
        return value
    elif type(value) == datetime.date:
        return value.strftime(ctx.get_date_format(False))
    elif isinstance(value, datetime.time):
        return value.strftime('%H:%M')
    elif isinstance(value, datetime.datetime):
        return value.astimezone(ctx.timezone).isoformat()

    raise EvaluationError("Can't convert '%s' to a string" % str(value))
693484
def _StrftimeGm(value, unused_context, args):
    
    time_tuple = time.gmtime(value)
    return _StrftimeHelper(args, time_tuple)
228425
def timestamp(value):
    
    value = value if timezone.is_naive(value) else timezone.localtime(value)
    return value.strftime(settings.DATE_FORMAT)
920622
def to_timestamp(val):
    
    # If we're given a number, give it right back - it's already a timestamp.
    if isinstance(val, numbers.Number):
        return val
    elif isinstance(val, six.string_types):
        dt = _parse_datetime_string(val)
    else:
        dt = val
    return time.mktime(dt.timetuple())
224065
def parse_unixtime(value)
      unless value.is_a?(String) || value.is_a?(Numeric)
        raise TimeParseError, "value must be a string or a number: #{value}(value.class)"
      end

      if @cache1_key == value
        return @cache1_time
      elsif @cache2_key == value
        return @cache2_time
      end

      begin
        time = Fluent::EventTime.new(value.to_i)
      rescue => e
        raise TimeParseError, "invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}"
      end
      @cache1_key = @cache2_key
      @cache1_time = @cache2_time
      @cache2_key = value
      @cache2_time = time
      time
    end
145179
public static OffsetTime toTime(Object value, EvaluationContext ctx) {
        if (value instanceof String) {
            OffsetTime time = ctx.getDateParser().time((String) value);
            if (time != null) {
                return time;
            }
        }
        else if (value instanceof OffsetTime) {
            return (OffsetTime) value;
        }
        else if (value instanceof ZonedDateTime) {
            return ((ZonedDateTime) value).toOffsetDateTime().toOffsetTime();
        }

        throw new EvaluationError("Can't convert '" + value + "' to a time");
    }
369989
def wrap(self, value, timestamp=None):
        
        if isinstance(value, Value):
            return value
        elif isinstance(value, ntwrappercommon):
            return value.raw
        elif isinstance(value, dict):
            return self.Value(self.type, value)
        else:
            S, NS = divmod(float(timestamp or time.time()), 1.0)
            return self.Value(self.type, {
                'value': value,
                'timeStamp': {
                    'secondsPastEpoch': S,
                    'nanoseconds': NS * 1e9,
                },
            })
1130731
def value_validate(self, value):
        
        if not isinstance(value, datetime.datetime):
            raise tldap.exceptions.ValidationError("is invalid date time")
222181
def valueFromString(self, value, context=None):
        
        if value in ('today', 'now'):
            return datetime.date.today()
        elif dateutil_parser:
            return dateutil_parser.parse(value).date()
        else:
            time_struct = time.strptime(value, self.defaultFormat())
            return datetime.date(time_struct.tm_year,
                                 time_struct.tm_month,
                                 time_struct.tm_day)
1363256
def get_if_handleable value
      case value
      when String then value
      when DateTime then value.to_time.utc.xmlschema(3)
      else nil
      end
    end
170770
def to_repr(value, ctx):
    
    as_string = to_string(value, ctx)

    if isinstance(value, str) or isinstance(value, datetime.date) or isinstance(value, datetime.time):
        as_string = as_string.replace('"', '""')  # escape quotes by doubling
        as_string = '"%s"' % as_string

    return as_string
385289
def check_time(value):
    """"""
    try:
        h, m = value.split(':')
        h = int(h)
        m = int(m)
        if h >= 24 or h < 0:
            raise ValueError
        if m >= 60 or m < 0:
            raise ValueError
    except ValueError:
        raise TimeDefinitionError("Invalid definition of time %r" % value)