Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: universal
api-designtimeclock-skewnaming
Pass a duration (TTL), not a precomputed timestamp, when the DB sets the time
If the database computes the base time with NOW(), have callers pass a named TTL duration (e.g. FILE_TTL_IN_MS) rather than a client-computed absolute date that can drift from server time.
PR: hegnar-journalist-boost · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | // client computes the date; drifts from DB clock |
| 2 | createFile({ expiresAt: new Date(Date.now() + 3600 * 1000) }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const FILE_TTL_IN_MS = 60 * 60 * 1000; // 1 hour |
| 2 | createFile({ fileTTLInMs: FILE_TTL_IN_MS }); |
| 3 | // query: expires_at = NOW() + (ttl_ms || ' milliseconds')::interval |
Explanation (EN)
Objašnjenje (HR)