🚚 Rename TS* to Timestamp
This commit is contained in:
parent
61a5199699
commit
63d538d889
2 changed files with 9 additions and 9 deletions
12
gen_ts.go
12
gen_ts.go
|
|
@ -34,24 +34,24 @@ func Timestamp(opts ...TimestampOption) Generator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TSFormat sets the format for the generated name.
|
// TimestampFormat sets the format for the generated name.
|
||||||
// Consult time.Time.Format for details on the format.
|
// Consult time.Time.Format for details on the format.
|
||||||
func TSFormat(format string) TimestampOption {
|
func TimestampFormat(format string) TimestampOption {
|
||||||
return func(c *timestampConf) {
|
return func(c *timestampConf) {
|
||||||
c.format = format
|
c.format = format
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TSTime sets the time for the generated name.
|
// TimestampTime sets the time for the generated name.
|
||||||
// By default, it uses the current time.
|
// By default, it uses the current time.
|
||||||
func TSTime(t time.Time) TimestampOption {
|
func TimestampTime(t time.Time) TimestampOption {
|
||||||
return func(c *timestampConf) {
|
return func(c *timestampConf) {
|
||||||
c.ts = t
|
c.ts = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TSUTC uses the time in UTC, while also stripping the timezone from the format.
|
// TimestampUTC uses the time in UTC, while also stripping the timezone from the format.
|
||||||
func TSUTC() TimestampOption {
|
func TimestampUTC() TimestampOption {
|
||||||
return func(c *timestampConf) {
|
return func(c *timestampConf) {
|
||||||
c.utc = true
|
c.utc = true
|
||||||
c.format = FileTimestampNoTZ
|
c.format = FileTimestampNoTZ
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
func ExampleTimestamp_withTime() {
|
func ExampleTimestamp_withTime() {
|
||||||
tz, _ := time.LoadLocation("America/New_York")
|
tz, _ := time.LoadLocation("America/New_York")
|
||||||
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
||||||
gen := nomino.Timestamp(nomino.TSTime(ts))
|
gen := nomino.Timestamp(nomino.TimestampTime(ts))
|
||||||
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
||||||
s, _ := nomino.Make(conf)
|
s, _ := nomino.Make(conf)
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
|
|
@ -20,7 +20,7 @@ func ExampleTimestamp_withTime() {
|
||||||
func ExampleTimestamp_withFormat() {
|
func ExampleTimestamp_withFormat() {
|
||||||
tz, _ := time.LoadLocation("America/New_York")
|
tz, _ := time.LoadLocation("America/New_York")
|
||||||
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
||||||
gen := nomino.Timestamp(nomino.TSTime(ts), nomino.TSFormat("2006#01#02<>15|04|05-0700"))
|
gen := nomino.Timestamp(nomino.TimestampTime(ts), nomino.TimestampFormat("2006#01#02<>15|04|05-0700"))
|
||||||
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
||||||
s, _ := nomino.Make(conf)
|
s, _ := nomino.Make(conf)
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
|
|
@ -30,7 +30,7 @@ func ExampleTimestamp_withFormat() {
|
||||||
func ExampleTimestamp_withUTC() {
|
func ExampleTimestamp_withUTC() {
|
||||||
tz, _ := time.LoadLocation("America/New_York")
|
tz, _ := time.LoadLocation("America/New_York")
|
||||||
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
ts := time.Date(2009, time.January, 20, 12, 5, 0, 0, tz)
|
||||||
gen := nomino.Timestamp(nomino.TSTime(ts), nomino.TSUTC())
|
gen := nomino.Timestamp(nomino.TimestampTime(ts), nomino.TimestampUTC())
|
||||||
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
conf := nomino.NewConfig(nomino.WithGenerator(gen))
|
||||||
s, _ := nomino.Make(conf)
|
s, _ := nomino.Make(conf)
|
||||||
fmt.Println(s)
|
fmt.Println(s)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue