INNER CODE UNIT · Python

source_date_epoch

stp/stp · lib/AST/genkinds.py:71

def source_date_epoch():
    """Reproduce Perl's `$ENV{SOURCE_DATE_EPOCH} || time`.

    Unset, empty and "0" are all false in Perl, so each falls back to the
    current time; anything else is numified the way Perl numifies a string,
    i.e. by taking its leading numeric prefix.
    """
    value = os.environ.get("SOURCE_DATE_EPOCH")
    if not value or value == "0":
        return time.time()

    match = re.match(r"\s*[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?", value)
    if not match:
        return 0.0
    return float(match.group(0))


def read_kind_defs(fname):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…