Refactor SetDate to use SetDateWithValue

Replaces direct time formatting in SetDate with a call to SetDateWithValue, improving code reusability and readability. The new approach centralizes date formatting logic in one method.
This commit is contained in:
Winni Neessen 2024-10-26 19:57:02 +02:00
parent ea5b02bfdd
commit ae15a12ce5
Signed by: wneessen
GPG key ID: 385AC9889632126E

3
msg.go
View file

@ -1087,8 +1087,7 @@ func (m *Msg) SetBulk() {
// - https://datatracker.ietf.org/doc/html/rfc5322#section-3.3 // - https://datatracker.ietf.org/doc/html/rfc5322#section-3.3
// - https://datatracker.ietf.org/doc/html/rfc1123 // - https://datatracker.ietf.org/doc/html/rfc1123
func (m *Msg) SetDate() { func (m *Msg) SetDate() {
now := time.Now().Format(time.RFC1123Z) m.SetDateWithValue(time.Now())
m.SetGenHeader(HeaderDate, now)
} }
// SetDateWithValue sets the "Date" header for the Msg using the provided time value in a valid RFC 1123 format. // SetDateWithValue sets the "Date" header for the Msg using the provided time value in a valid RFC 1123 format.