[ADP-703] Date and Time Field Conventions
Guidelines
- Date and time fields SHOULD use a suffix that reflects the data type:
Atfor datetime fields representing a point-in-time instant (e.g.,createdAt,expiredAt)Datefor date-only fields with no time component (e.g.,birthDate,startDate)Timefor time-of-day or contextual time fields (e.g.,checkoutTime,cutoffTime)
- When both
AtandTimecould apply, preferAtfor system-generated point-in-time instants. - Other common terms (
timestamp,day) MAY be used when they fit the domain language naturally. - Date and time values MUST be represented using the RFC 3339 format.
Design Considerations
Using a type-specific suffix clearly indicates the data format without requiring a documentation lookup. A good API should be able to semantically describe itself.
- Why not bare names? Fields like
created,deleted, orstartare ambiguous -- they could be booleans, strings, or timestamps. Adding a suffix (createdAt,startDate) eliminates this ambiguity. - Why distinguish
At,Date, andTime? Different suffixes communicate the expected format:Atsignals a full RFC 3339 datetime with timezone,Datesignals a date-only value (YYYY-MM-DD), andTimesignals a time-of-day or contextual time concept. WritingbirthAtreads unnaturally;birthDateis both clearer and more idiomatic. - When
AtandTimeoverlap: For system-generated lifecycle instants (creation, modification, deletion, expiration), preferAt. ReserveTimefor cases where "time" is part of the natural domain language (e.g.,checkoutTime,arrivalTime).
For the representation of values, please refer to the requirements for using the RFC 3339 format for date and time.
RFC3339 Format Overview
Refer to the original specification or RFC3339 Overview
Examples
Datetime fields (point-in-time instants) -- use At:
json
{
"createdAt": "2023-10-12T08:00:00Z",
"updatedAt": "2023-10-12T09:30:00Z",
"expiredAt": "2024-01-01T00:00:00Z"
}Date-only fields -- use Date:
json
{
"birthDate": "1990-05-15",
"startDate": "2024-01-01",
"dueDate": "2024-03-31"
}Contextual time fields -- use Time:
json
{
"checkoutTime": "2023-10-12T12:00:00Z",
"arrivalTime": "2023-10-12T14:30:00Z",
"cutoffTime": "17:00:00"
}DON'T -- bare names without suffixes are ambiguous:
json
{
"start": "2023-10-12T08:00:00Z",
"end": "2023-10-12T10:00:00Z",
"created": "2023-10-12T10:00:00Z"
}