Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Determine if arg is a timestamp and if so what format

Args:
   time_str - character string that may be a date, time, epoch or combo
Returns:
   status   - True if date/time False if not
   scope    - kind of timestamp
   pattern  - date mask

To do:(more...)

        def is_timestamp(time_str):
    """ Determine if arg is a timestamp and if so what format

        Args:
           time_str - character string that may be a date, time, epoch or combo
        Returns:
           status   - True if date/time False if not
           scope    - kind of timestamp
           pattern  - date mask

        To do:
           - consider overrides to default date min & max epoch limits
           - consider consolidating epoch checks with rest of checks
    """
    non_date = (False, None, None)
    if len(time_str) > DATE_MAX_LEN:
        return non_date

    try:
        float_str = float(time_str)
        if DATE_MIN_EPOCH_DEFAULT < float_str < DATE_MAX_EPOCH_DEFAULT:
            t_date = datetime.datetime.fromtimestamp(float(time_str))
            return True, 'second', 'epoch'
    except ValueError:
        pass

    for scope, pattern, date_format in DATE_FORMATS:
        if scope == "microsecond":
            # Special handling for microsecond part. AFAIK there isn't a
            # strftime code for this.
            if time_str.count('.') != 1:
                continue
            time_str, microseconds_str = time_str.split('.')
            try:
                microsecond = int((microseconds_str + '000000')[:6])
            except ValueError:
                continue
        try:
            t_date = datetime.datetime.strptime(time_str, date_format)
        except ValueError:
            pass
        else:
            if scope == "microsecond":
                t_date = t_date.replace(microsecond=microsecond)
            return True, scope, pattern
    else:
        return False,  None, None
        


src/d/a/datagristle-0.56/gristle/tests/test_field_type.py   datagristle(Download)
    def runner(self, date):
        result, scope, pattern = mod.is_timestamp(date)
        return result, scope
 
    def test_is_timestamp_bad_dates(self):

src/d/a/DataGristle-HEAD/gristle/tests/test_field_type.py   DataGristle(Download)
    def runner(self, date):
        result, scope, pattern = mod.is_timestamp(date)
        return result, scope
 
    def test_is_timestamp_bad_dates(self):