mirror of
https://github.com/golang/go
synced 2024-11-25 09:07:58 -07:00
net/mail: add example for ParseDate
Change-Id: Id22d199ea4b0a9795dc3d9e5f7a74be13ff0cf58 Reviewed-on: https://go-review.googlesource.com/c/go/+/618755 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
5428570af7
commit
93166e29d3
@ -10,6 +10,7 @@ import (
|
||||
"log"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ExampleParseAddressList() {
|
||||
@ -75,3 +76,17 @@ Message body
|
||||
// Subject: Gophers at Gophercon
|
||||
// Message body
|
||||
}
|
||||
|
||||
func ExampleParseDate() {
|
||||
dateStr := "Wed, 09 Oct 2024 09:55:06 -0700"
|
||||
|
||||
t, err := mail.ParseDate(dateStr)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse date: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println(t.Format(time.RFC3339))
|
||||
|
||||
// Output:
|
||||
// 2024-10-09T09:55:06-07:00
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user