mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Renamed Option to ParserOption to narrow scope and leave room for other features that may have options
This commit is contained in:
parent
e151913243
commit
f8deff45a7
@ -209,7 +209,7 @@ func ParseStrict(datestr string) (time.Time, error) {
|
|||||||
return p.parse()
|
return p.parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTime(datestr string, loc *time.Location, opts ...Option) (*parser, error) {
|
func parseTime(datestr string, loc *time.Location, opts ...ParserOption) (*parser, error) {
|
||||||
|
|
||||||
p := newParser(datestr, loc, opts...)
|
p := newParser(datestr, loc, opts...)
|
||||||
i := 0
|
i := 0
|
||||||
@ -1711,17 +1711,17 @@ type parser struct {
|
|||||||
t *time.Time
|
t *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type Option func(*parser) error
|
type ParserOption func(*parser) error
|
||||||
|
|
||||||
// PreferMonthFirst is an option that allows preferMonthFirst to be changed from its default
|
// PreferMonthFirst is an option that allows preferMonthFirst to be changed from its default
|
||||||
func PreferMonthFirst(preferMonthFirst bool) Option {
|
func PreferMonthFirst(preferMonthFirst bool) ParserOption {
|
||||||
return func(p *parser) error {
|
return func(p *parser) error {
|
||||||
p.preferMonthFirst = preferMonthFirst
|
p.preferMonthFirst = preferMonthFirst
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newParser(dateStr string, loc *time.Location, opts ...Option) *parser {
|
func newParser(dateStr string, loc *time.Location, opts ...ParserOption) *parser {
|
||||||
p := &parser{
|
p := &parser{
|
||||||
stateDate: dateStart,
|
stateDate: dateStart,
|
||||||
stateTime: timeIgnore,
|
stateTime: timeIgnore,
|
||||||
|
Loading…
Reference in New Issue
Block a user