- Archiver 131 .md dans docs/archive/root-md/ - Archiver 22 .json dans docs/archive/root-json/ - Conserver 7 .md utiles (README, CONTRIBUTING, CHANGELOG, etc.) - Conserver package.json, package-lock.json, turbo.json - Ajouter README d'index dans chaque archive
3.4 KiB
3.4 KiB
Date/Time Format Standardization
INT-008: Standardize date/time formats
Date: 2025-12-25
Status: Completed
Summary
All date and time values in Veza API responses now use ISO 8601 (RFC3339) format consistently.
Standard Date/Time Format
All dates and timestamps use ISO 8601 (RFC3339) format:
- Format:
YYYY-MM-DDTHH:mm:ssZorYYYY-MM-DDTHH:mm:ss.sssZ - Example:
2025-12-25T10:30:00Zor2025-12-25T10:30:00.123Z - Timezone: Always UTC (indicated by
Zsuffix)
Implementation
Backend
All date/time formatting is now standardized through:
-
time.RFC3339(Go standard library):- Used throughout the codebase for consistent formatting
- Ensures ISO 8601 compliance
- Always uses UTC timezone
-
utils.FormatISO8601(internal/utils/datetime.go):- Helper function for formatting
time.Timeto ISO 8601 - Automatically converts to UTC
- Used for manual date formatting
- Helper function for formatting
-
utils.FormatISO8601Ptr(internal/utils/datetime.go):- Helper for nullable
*time.Timefields - Returns empty string if nil
- Helper for nullable
-
utils.ParseISO8601(internal/utils/datetime.go):- Helper for parsing ISO 8601 strings
- Used for date input validation
-
Model Updates:
UserResponse.FromUser: Usestime.RFC3339instead of custom format- All
time.Timefields in models are automatically serialized by Go's JSON encoder - GORM models use
time.Timewhich serializes correctly
Frontend
The frontend already expects ISO 8601 format:
- JavaScript
Dateconstructor parses ISO 8601 automatically - All date parsing/formatting libraries support ISO 8601
- No frontend changes required
Changes Made
Backend Changes
-
internal/models/responses.go:- Updated
FromUserto usetime.RFC3339instead of"2006-01-02T15:04:05Z" - Added
timeimport - Ensures UTC timezone with
.UTC()
- Updated
-
internal/handlers/webhook_handlers.go:- Updated webhook test timestamp to use
time.RFC3339 - Ensures consistent format in webhook payloads
- Updated webhook test timestamp to use
-
internal/utils/datetime.go(new file):- Created helper functions for date formatting
FormatISO8601: Formats time.Time to ISO 8601FormatISO8601Ptr: Formats nullable *time.TimeParseISO8601: Parses ISO 8601 strings
-
Error Responses:
- Already using
time.RFC3339inerror_response.go - No changes needed
- Already using
Model Serialization
GORM models with time.Time fields are automatically serialized correctly:
- Go's JSON encoder uses RFC3339 format by default for
time.Time - All model fields like
CreatedAt,UpdatedAtare correctly formatted - No additional changes needed for models
Migration Notes
- All manual date formatting now uses
time.RFC3339 - Custom format strings like
"2006-01-02T15:04:05Z"replaced withtime.RFC3339 - All timestamps are in UTC timezone
- Frontend automatically handles ISO 8601 format
Files Modified
veza-backend-api/internal/models/responses.goveza-backend-api/internal/handlers/webhook_handlers.go- Created:
veza-backend-api/internal/utils/datetime.go - Created:
DATETIME_STANDARD.md(this document)
Next Steps
- ✅ Standardize all date formatting to RFC3339
- ✅ Create helper functions for date formatting
- ✅ Update manual date formatting in responses
- ✅ Verify model serialization
- ⏳ Add integration tests for date format validation