Files
sideeyes-koans-plugin/koans/lib.py
2025-09-04 03:19:00 +10:00

20 lines
460 B
Python

from typing import Optional
import datetime as dt
from datetime import datetime
def minify(content: str, maxlength: int, strip: Optional[str] = ' ', newlines: str = ' '):
content.replace('\n', newlines)
if strip:
content = content.strip(strip)
if len(content) > maxlength:
new_content = content[:maxlength-3] + '...'
else:
new_content = content
return new_content
def utc_now():
return datetime.now(dt.UTC)