25 lines
704 B
Go
25 lines
704 B
Go
package utils
|
|
|
|
import "time"
|
|
|
|
// FormatISO8601 formats a time.Time to ISO 8601 (RFC3339) format
|
|
// INT-008: Standardize date format helper
|
|
func FormatISO8601(t time.Time) string {
|
|
return t.UTC().Format(time.RFC3339)
|
|
}
|
|
|
|
// FormatISO8601Ptr formats a *time.Time to ISO 8601 (RFC3339) format
|
|
// Returns empty string if nil
|
|
// INT-008: Standardize date format helper for nullable times
|
|
func FormatISO8601Ptr(t *time.Time) string {
|
|
if t == nil {
|
|
return ""
|
|
}
|
|
return t.UTC().Format(time.RFC3339)
|
|
}
|
|
|
|
// ParseISO8601 parses an ISO 8601 (RFC3339) formatted string to time.Time
|
|
// INT-008: Standardize date parsing helper
|
|
func ParseISO8601(s string) (time.Time, error) {
|
|
return time.Parse(time.RFC3339, s)
|
|
}
|