Documentation
¶
Overview ¶
Package timereplace provides the Replace() function equivalent to Python's date.replace.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Replace ¶
Replace returns a new time.Time with some of the values in the given time.Time argument overwritten. The value to be rewritten is an element of the argument Values that is not nil.
Example ¶
package main
import (
"fmt"
"time"
"github.com/koron-go/timereplace"
)
func main() {
origtime := time.Date(2006, 1, 2, 3, 4, 5, 999999999, time.UTC)
fmt.Println(origtime.Format(time.RFC3339Nano))
modtime := timereplace.Replace(origtime, timereplace.Values{
Year: new(2026),
Month: new(time.Month(2)),
Day: new(19),
})
fmt.Println(modtime.Format(time.RFC3339Nano))
}
Output: 2006-01-02T03:04:05.999999999Z 2026-02-19T03:04:05.999999999Z
Types ¶
Click to show internal directories.
Click to hide internal directories.