Documentation
¶
Overview ¶
Package time contains some useful functions to manage timestamps in the same representation that PostgreSQL uses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToPostgresFormat ¶
ConvertToPostgresFormat converts timestamps to PostgreSQL time format, if needed. e.g. "2006-01-02T15:04:05Z07:00" --> "2006-01-02 15:04:05.000000+07:00". If the input is already in PostgreSQL timestamp format, it is returned unchanged.
This function assumes the input to be in one of RFC3339, RFC3339Micro, PostgreSQL, or RFC3339-like without timezone formats. It does not validate its input.
NOTE: for RFC3339 formatted times in UTC zone, the "Z" suffix is changed to "+00:00" to avoid problems when used for recovery_target_time.
NOTE: RFC3339-like timestamps without timezone (e.g., "2006-01-02T15:04:05") are interpreted as UTC and output with explicit +00:00 suffix. This ensures consistency with ParseTargetTime in pkg/types/time.go which also interprets such timestamps as UTC.
func DifferenceBetweenTimestamps ¶
DifferenceBetweenTimestamps returns the time.Duration difference between two timestamps strings in time.RFC3339.
func GetCurrentTimestamp ¶
func GetCurrentTimestamp() string
GetCurrentTimestamp returns the current timestamp as a string in RFC3339Micro format
func GetCurrentTimestampWithFormat ¶
GetCurrentTimestampWithFormat returns the current timestamp as a string with the specified format
func ToCompactISO8601 ¶
ToCompactISO8601 converts a time.Time into a compacted version of the ISO8601 timestamp, removing any separators for brevity.
For example:
Given: 2022-01-02 15:04:05 (UTC) Returns: 20220102150405
This compact format is useful for generating concise, yet human-readable timestamps that can serve as suffixes for backup-related objects or any other contexts where space or character count might be a concern.
Types ¶
This section is empty.