Document naive-datetime host time zone behaviour; use aware datetimes in examples - #55
Conversation
…re datetimes in examples Refs #50. Option 1 from the issue: no behaviour change, the API reference warns about the host-TZ dependence, and every example that hands a datetime to CEL now uses datetime.now(timezone.utc).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8a25aa1e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| now = datetime.now(timezone.utc) | ||
| delta = expiry - now |
There was a problem hiding this comment.
Preserve support for offset-less expiry strings
When expiry_date_str is a valid ISO-8601 value without an offset, datetime.fromisoformat() returns a naive datetime, so subtracting the newly aware now raises TypeError; the broad handler then silently returns 0 and treats even a future subscription as expired. Either require and validate an offset explicitly or attach the intended timezone before performing the subtraction.
Useful? React with 👍 / 👎.
| def is_business_hours(): | ||
| # For testing purposes, always return True | ||
| # In production, use: datetime.now().hour to check 9 <= hour <= 17 | ||
| # In production, use: datetime.now(timezone.utc).hour to check 9 <= hour <= 17 |
There was a problem hiding this comment.
Check business hours in the business timezone
For organizations whose business hours are not defined in UTC, this production recommendation checks the wrong clock—for example, 09:00 in Auckland is 20:00 or 21:00 UTC on the preceding day. Since only the integer hour is used and no datetime crosses into CEL here, switching to UTC does not address the naive-datetime conversion issue; the example should use the organization's explicit ZoneInfo timezone instead.
Useful? React with 👍 / 👎.
Refs #50, option 1 (document, no behaviour change).
datetime.now(timezone.utc).extending-celtutorial and theContext.add_variabledocstring switch from naivedatetime.now()to timezone-aware values. Snippets that only pass.hourintegers into CEL are unchanged since no datetime crosses the boundary there.Verified: doc snippets execute (
tests/test_docs.py,tests/test_documentation.py),cargo fmt --check. Empirical demonstration of the problem withTZ=Pacific/Auckland:cel.evaluate('now', {'now': datetime(2026,1,1,14)})returns2026-01-01 14:00:00+13:00, i.e. 01:00Z, where a UTC host gives 14:00Z.