feat: support optional start/end time on events
event_start_date / event_end_date now accept either YYYY-MM-DD (date-only) or YYYY-MM-DDTHH:MM (ISO datetime). The NIP-52 publisher switches kind on the "T" delimiter: kind 31922 (date-based, YYYY-MM-DD start/end) when absent, kind 31923 (time-based, unix-timestamp start/end + day-granularity D tags) when present. Delete events match the original publish kind. Closing-date parsing accepts both formats. The LNbits admin form gains optional HH:MM inputs alongside each date picker; they fold into the wire-format string on submit and split back on edit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6aa280680e
commit
df4775126f
5 changed files with 138 additions and 32 deletions
13
views_api.py
13
views_api.py
|
|
@ -151,9 +151,16 @@ async def api_get_event(event_id: str) -> Event:
|
|||
closing_date = (
|
||||
event.closing_date or event.event_end_date or event.event_start_date
|
||||
)
|
||||
is_window_open = datetime.now(timezone.utc) < datetime.strptime(
|
||||
closing_date, "%Y-%m-%d"
|
||||
).replace(tzinfo=timezone.utc)
|
||||
# Accept either YYYY-MM-DD or full ISO 8601 datetime (event_end_date
|
||||
# may carry a time component since v1.3.0-aio.3 / our start-end-time
|
||||
# feature).
|
||||
try:
|
||||
closing_dt = datetime.fromisoformat(closing_date)
|
||||
except ValueError:
|
||||
closing_dt = datetime.strptime(closing_date[:10], "%Y-%m-%d")
|
||||
if closing_dt.tzinfo is None:
|
||||
closing_dt = closing_dt.replace(tzinfo=timezone.utc)
|
||||
is_window_open = datetime.now(timezone.utc) < closing_dt
|
||||
is_min_tickets_met = (
|
||||
event.sold >= event.extra.min_tickets if event.extra.conditional else True
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue