package main
import (
"fmt"
"log"
"time"
"github.com/lestrrat-go/strftime"
)
func main() {
t := time.Date(2020, 07, 24, 9, 8, 7, 0, time.UTC)
str, err := strftime.Format("%I:%M:%S %p", t)
if err != nil {
log.Fatal(err)
}
fmt.Println(str) // 9:08:07 AM but should be 09:08:07 AM
str, err = strftime.Format("%r", t)
if err != nil {
log.Fatal(err)
}
fmt.Println(str) // 9:08:07 AM but should be 09:08:07 AM
}
Description
As title,
%I
and%r
should pad zero for 1-9.Sample code
For reference,