MCPcopy
hub / github.com/github/awesome-copilot / validate_iso_date

Function validate_iso_date

skills/quality-playbook/quality_gate.py:629–649  ·  view source on GitHub ↗

Return one of: 'valid', 'placeholder', 'future', 'bad_format', 'empty'. Placeholders are checked before format so that 'YYYY-MM-DD' is reported as 'placeholder' rather than 'bad_format'. The bash version's order was flipped, causing 'YYYY-MM-DD' to be misreported — both still FAIL but t

(date_str)

Source from the content-addressed store, hash-verified

627
628
629def validate_iso_date(date_str):
630 """Return one of: 'valid', 'placeholder', 'future', 'bad_format', 'empty'.
631
632 Placeholders are checked before format so that 'YYYY-MM-DD' is reported
633 as 'placeholder' rather than 'bad_format'. The bash version's order was
634 flipped, causing 'YYYY-MM-DD' to be misreported — both still FAIL but the
635 Python version gives the clearer message.
636 """
637 if not date_str:
638 return "empty"
639 if date_str in ("YYYY-MM-DD", "0000-00-00"):
640 return "placeholder"
641 date_part = date_str[:10]
642 if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", date_part):
643 return "bad_format"
644 if len(date_str) > 10 and not re.fullmatch(r"T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})?", date_str[10:]):
645 return "bad_format"
646 today = date.today().isoformat()
647 if date_part > today:
648 return "future"
649 return "valid"
650
651
652def detect_skill_version(locations):

Callers 3

check_tdd_sidecarFunction · 0.85
check_recheck_sidecarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected