_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q20300
initRewrite
train
func initRewrite(rewriteRule string) rewrite { f := strings.Split(rewriteRule, "->") if len(f) != 2 { fmt.Fprintf(os.Stderr, "rewrite rule must be of the form 'pattern -> replacement'\n") os.Exit(2) } pattern := parseExpr(f[0], "pattern") replace := parseExpr(f[1], "replacement") return func(p *ast.File) *ast...
go
{ "resource": "" }
q20301
parseExpr
train
func parseExpr(s, what string) ast.Expr { x, err := parser.ParseExpr(s) if err != nil { fmt.Fprintf(os.Stderr, "parsing %s %s at %s\n", what, s, err) os.Exit(2) } return x }
go
{ "resource": "" }
q20302
subst
train
func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value) reflect.Value { if !pattern.IsValid() { return reflect.Value{} } // Wildcard gets replaced with map value. if m != nil && pattern.Type() == identType { name := pattern.Interface().(*ast.Ident).Name if isWildcard(name) { if ol...
go
{ "resource": "" }
q20303
NewOpt
train
func NewOpt(o *container.Container, index map[string]*container.Container) Matcher { return &opt{ theOne: o, index: index, } }
go
{ "resource": "" }
q20304
NewParseContext
train
func NewParseContext() ParseContext { return ParseContext{ Args: map[*container.Container][]string{}, Opts: map[*container.Container][]string{}, ExcludedOpts: map[*container.Container]struct{}{}, RejectOptions: false, } }
go
{ "resource": "" }
q20305
Merge
train
func (pc ParseContext) Merge(o ParseContext) { for k, vs := range o.Args { pc.Args[k] = append(pc.Args[k], vs...) } for k, vs := range o.Opts { pc.Opts[k] = append(pc.Opts[k], vs...) } }
go
{ "resource": "" }
q20306
T
train
func (s *State) T(matcher matcher.Matcher, next *State) *State { s.Transitions = append(s.Transitions, &Transition{Matcher: matcher, Next: next}) return next }
go
{ "resource": "" }
q20307
Prepare
train
func (s *State) Prepare() { simplify(s, s, map[*State]bool{}) sortTransitions(s, map[*State]bool{}) }
go
{ "resource": "" }
q20308
Parse
train
func (s *State) Parse(args []string) error { pc := matcher.NewParseContext() ok := s.apply(args, pc) if !ok { return fmt.Errorf("incorrect usage") } if err := fillContainers(pc.Opts); err != nil { return err } return fillContainers(pc.Args) }
go
{ "resource": "" }
q20309
IsBool
train
func IsBool(v flag.Value) bool { if bf, ok := v.(BoolValued); ok { return bf.IsBoolFlag() } return false }
go
{ "resource": "" }
q20310
SetFromEnv
train
func SetFromEnv(into flag.Value, envVars string) bool { multiValued, isMulti := into.(MultiValued) if len(envVars) > 0 { for _, ev := range strings.Fields(envVars) { v := os.Getenv(ev) if len(v) == 0 { continue } if !isMulti { if err := into.Set(v); err == nil { return true } conti...
go
{ "resource": "" }
q20311
Parse
train
func Parse(tokens []*lexer.Token, params Params) (*fsm.State, error) { p := &parser{ spec: params.Spec, options: params.Options, optionsIdx: params.OptionsIdx, args: params.Args, argsIdx: params.ArgsIdx, tokens: tokens, } return p.parse() }
go
{ "resource": "" }
q20312
Dot
train
func Dot(s *fsm.State) string { trs := dot(s, mkStateNames(), map[*fsm.State]struct{}{}) return fmt.Sprintf("digraph G {\n\trankdir=LR\n%s\n}\n", strings.Join(trs, "\n")) }
go
{ "resource": "" }
q20313
NewBool
train
func NewBool(into *bool, v bool) *BoolValue { *into = v return (*BoolValue)(into) }
go
{ "resource": "" }
q20314
NewString
train
func NewString(into *string, v string) *StringValue { *into = v return (*StringValue)(into) }
go
{ "resource": "" }
q20315
NewInt
train
func NewInt(into *int, v int) *IntValue { *into = v return (*IntValue)(into) }
go
{ "resource": "" }
q20316
NewFloat64
train
func NewFloat64(into *float64, v float64) *Float64Value { *into = v return (*Float64Value)(into) }
go
{ "resource": "" }
q20317
NewStrings
train
func NewStrings(into *[]string, v []string) *StringsValue { *into = v return (*StringsValue)(into) }
go
{ "resource": "" }
q20318
NewInts
train
func NewInts(into *[]int, v []int) *IntsValue { *into = v return (*IntsValue)(into) }
go
{ "resource": "" }
q20319
NewFloats64
train
func NewFloats64(into *[]float64, v []float64) *Floats64Value { *into = v return (*Floats64Value)(into) }
go
{ "resource": "" }
q20320
NewOptions
train
func NewOptions(opts []*container.Container, index map[string]*container.Container) Matcher { return &options{ options: opts, index: index, } }
go
{ "resource": "" }
q20321
Exists
train
func (d *Dir) Exists(newDir string) bool { for _, dir := range d.Blacklist { if dir == newDir { return true } } return false }
go
{ "resource": "" }
q20322
Parse
train
func (d *Dir) Parse(newDir string) []string { list := strings.Split(newDir, "/") var dirWalk []string for indx := range list { dirList := "" for i := -1; i < indx; i++ { dirList += list[i+1] + "/" } if !d.Exists(dirList) { if strings.HasSuffix(dirList, "//") { dirList = dirList[:len(dirList)-1] ...
go
{ "resource": "" }
q20323
Insert
train
func (d *Dir) Insert(newDir string) { if !d.Exists(newDir) { d.Blacklist = append(d.Blacklist, newDir) d.List = append(d.List, d.Parse(newDir)) } }
go
{ "resource": "" }
q20324
Get
train
func (up *Updater) Get() error { log.Println("Creating hash list request...") req, err := http.NewRequest("GET", up.Server, nil) if err != nil { return err } req.SetBasicAuth(up.Auth.Username, up.Auth.Password) log.Println("Sending hash list request...") client := &http.Client{} resp, err := client.Do(req) ...
go
{ "resource": "" }
q20325
Updatable
train
func (up *Updater) Updatable(files map[string]*file.File) (bool, error) { hasUpdates := !up.EqualHashes(files) if hasUpdates { log.Println("----------------------------------------") log.Println("-- Found files that should be updated --") log.Println("----------------------------------------") } else { log....
go
{ "resource": "" }
q20326
EqualHashes
train
func (up *Updater) EqualHashes(files map[string]*file.File) bool { for _, f := range files { log.Println("Checking file for changes:", f.Path) if len(f.Bytes) == 0 && !f.ReplacedText { data, err := ioutil.ReadFile(f.OriginalPath) if err != nil { panic(err) } f.Bytes = data // removes the []by...
go
{ "resource": "" }
q20327
UpdateFiles
train
func (up *Updater) UpdateFiles(files map[string]*file.File) error { updatable, err := up.Updatable(files) if err != nil { return err } if !updatable { return nil } // everything's height height := 3 err = termui.Init() if err != nil { panic(err) } defer termui.Close() // info text p := termui.NewP...
go
{ "resource": "" }
q20328
Set
train
func (t *Template) Set(name string) error { t.name = name if name != "files" && name != "file" { return errors.New(`Error: Template must be "files" or "file"`) } if name == "files" { t.template = filesTemplate } else if name == "file" { t.template = fileTemplate } return nil }
go
{ "resource": "" }
q20329
Exec
train
func (t *Template) Exec() ([]byte, error) { tmpl, err := template.New(t.name).Funcs(funcsTemplate).Parse(t.template) if err != nil { return nil, err } // exec template buff := bytes.NewBufferString("") err = tmpl.Execute(buff, t.Variables) if err != nil { return nil, err } return buff.Bytes(), nil }
go
{ "resource": "" }
q20330
Defaults
train
func (cfg *Config) Defaults() error { // default destination if cfg.Dest == "" { cfg.Dest = "/" } // insert "/" at end of dest when it's not found if !strings.HasSuffix(cfg.Dest, "/") { cfg.Dest += "/" } // default file name if cfg.Output == "" { cfg.Output = "b0x.go" } // inserts .go at the end of f...
go
{ "resource": "" }
q20331
Parse
train
func (f *File) Parse() (*Config, error) { // remove comments f.RemoveJSONComments() to := &Config{} switch f.Mode { case "json": return to, json.Unmarshal(f.Data, to) case "yaml", "yml": return to, yaml.Unmarshal(f.Data, to) case "toml": return to, toml.Unmarshal(f.Data, to) default: return nil, fmt.Er...
go
{ "resource": "" }
q20332
RemoveJSONComments
train
func (f *File) RemoveJSONComments() { if f.Mode == "json" { // remove inline comments f.Data = []byte(regexComments.ReplaceAllString(string(f.Data), "")) } }
go
{ "resource": "" }
q20333
NewGzip
train
func NewGzip() *Gzip { gz := new(Gzip) gz.Options = new(Options) return gz }
go
{ "resource": "" }
q20334
Compress
train
func (gz *Gzip) Compress(content []byte) ([]byte, error) { if !gz.Options.Compress { return content, nil } // method var m int switch gz.Options.Method { case "NoCompression": m = flate.NoCompression break case "BestSpeed": m = flate.BestSpeed break case "BestCompression": m = flate.BestCompression...
go
{ "resource": "" }
q20335
GetCurrentDir
train
func GetCurrentDir() (string, error) { d, err := filepath.Abs(filepath.Dir(os.Args[0])) return d, err }
go
{ "resource": "" }
q20336
NewCarbon
train
func NewCarbon(t time.Time) *Carbon { wds := []time.Weekday{ time.Saturday, time.Sunday, } return &Carbon{ Time: t, weekStartsAt: time.Monday, weekEndsAt: time.Sunday, weekendDays: wds, stringFormat: DefaultFormat, Translator: translator(), } }
go
{ "resource": "" }
q20337
After
train
func After(d time.Duration) <-chan time.Time { if isTimeFrozen { currentFrozenTime = currentFrozenTime.Add(d) c := make(chan time.Time, 1) c <- currentFrozenTime return c } return time.After(d) }
go
{ "resource": "" }
q20338
Sleep
train
func Sleep(d time.Duration) { if isTimeFrozen && d > 0 { currentFrozenTime = currentFrozenTime.Add(d) return } time.Sleep(d) }
go
{ "resource": "" }
q20339
create
train
func create(y int, mon time.Month, d, h, m, s, ns int, l *time.Location) *Carbon { return NewCarbon(time.Date(y, mon, d, h, m, s, ns, l)) }
go
{ "resource": "" }
q20340
Create
train
func Create(y int, mon time.Month, d, h, m, s, ns int, location string) (*Carbon, error) { l, err := time.LoadLocation(location) if err != nil { return nil, err } return create(y, mon, d, h, m, s, ns, l), nil }
go
{ "resource": "" }
q20341
CreateFromTime
train
func CreateFromTime(h, m, s, ns int, location string) (*Carbon, error) { y, mon, d := Now().Date() return Create(y, mon, d, h, m, s, ns, location) }
go
{ "resource": "" }
q20342
CreateFromFormat
train
func CreateFromFormat(layout, value string, location string) (*Carbon, error) { l, err := time.LoadLocation(location) if err != nil { return nil, err } t, err := time.ParseInLocation(layout, value, l) if err != nil { return nil, err } return NewCarbon(t), nil }
go
{ "resource": "" }
q20343
CreateFromTimestamp
train
func CreateFromTimestamp(timestamp int64, location string) (*Carbon, error) { l, err := time.LoadLocation(location) if err != nil { return nil, err } t := NewCarbon(Now().In(l)) t.SetTimestamp(timestamp) return t, nil }
go
{ "resource": "" }
q20344
CreateFromMonthAndYear
train
func CreateFromMonthAndYear(y int, mon time.Month, location string) (*Carbon, error) { _, _, d := Now().Date() h, m, s := Now().Clock() ns := Now().Nanosecond() return Create(y, mon, d, h, m, s, ns, location) }
go
{ "resource": "" }
q20345
Today
train
func Today(location string) (*Carbon, error) { l, err := time.LoadLocation(location) if err != nil { return nil, err } return NewCarbon(Now().In(l)), err }
go
{ "resource": "" }
q20346
Tomorrow
train
func Tomorrow(location string) (*Carbon, error) { c, err := Today(location) if err != nil { return nil, err } return c.AddDay(), nil }
go
{ "resource": "" }
q20347
Yesterday
train
func Yesterday(location string) (*Carbon, error) { c, err := Today(location) if err != nil { return nil, err } return c.SubDay(), nil }
go
{ "resource": "" }
q20348
Copy
train
func (c *Carbon) Copy() *Carbon { return create(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20349
Quarter
train
func (c *Carbon) Quarter() int { month := c.Month() switch { case month < 4: return 1 case month >= 4 && month < 7: return 2 case month >= 7 && month < 10: return 3 } return 4 }
go
{ "resource": "" }
q20350
WeekOfMonth
train
func (c *Carbon) WeekOfMonth() int { w := math.Ceil(float64(c.Day() / daysPerWeek)) return int(w + 1) }
go
{ "resource": "" }
q20351
AddYears
train
func (c *Carbon) AddYears(y int) *Carbon { return NewCarbon(c.AddDate(y, 0, 0)) }
go
{ "resource": "" }
q20352
AddQuarters
train
func (c *Carbon) AddQuarters(q int) *Carbon { return NewCarbon(c.AddDate(0, monthsPerQuarter*q, 0)) }
go
{ "resource": "" }
q20353
AddCenturies
train
func (c *Carbon) AddCenturies(cent int) *Carbon { return NewCarbon(c.AddDate(yearsPerCenturies*cent, 0, 0)) }
go
{ "resource": "" }
q20354
AddMonths
train
func (c *Carbon) AddMonths(m int) *Carbon { return NewCarbon(c.AddDate(0, m, 0)) }
go
{ "resource": "" }
q20355
AddSeconds
train
func (c *Carbon) AddSeconds(s int) *Carbon { d := time.Duration(s) * time.Second return NewCarbon(c.Add(d)) }
go
{ "resource": "" }
q20356
AddDays
train
func (c *Carbon) AddDays(d int) *Carbon { return NewCarbon(c.AddDate(0, 0, d)) }
go
{ "resource": "" }
q20357
AddWeekdays
train
func (c *Carbon) AddWeekdays(wd int) *Carbon { d := 1 if wd < 0 { wd, d = -wd, -d } t := c.Copy() for wd > 0 { t = t.AddDays(d) if t.IsWeekday() { wd-- } } return t }
go
{ "resource": "" }
q20358
AddWeeks
train
func (c *Carbon) AddWeeks(w int) *Carbon { return NewCarbon(c.AddDate(0, 0, daysPerWeek*w)) }
go
{ "resource": "" }
q20359
AddHours
train
func (c *Carbon) AddHours(h int) *Carbon { d := time.Duration(h) * time.Hour return NewCarbon(c.Add(d)) }
go
{ "resource": "" }
q20360
AddMonthsNoOverflow
train
func (c *Carbon) AddMonthsNoOverflow(m int) *Carbon { addedDate := NewCarbon(c.AddDate(0, m, 0)) if c.Day() != addedDate.Day() { return addedDate.PreviousMonthLastDay() } return addedDate }
go
{ "resource": "" }
q20361
AddMinutes
train
func (c *Carbon) AddMinutes(m int) *Carbon { d := time.Duration(m) * time.Minute return NewCarbon(c.Add(d)) }
go
{ "resource": "" }
q20362
SetYear
train
func (c *Carbon) SetYear(y int) { c.Time = time.Date(y, c.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20363
SetMonth
train
func (c *Carbon) SetMonth(m time.Month) { c.Time = time.Date(c.Year(), m, c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20364
SetDay
train
func (c *Carbon) SetDay(d int) { c.Time = time.Date(c.Year(), c.Month(), d, c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20365
SetHour
train
func (c *Carbon) SetHour(h int) { c.Time = time.Date(c.Year(), c.Month(), c.Day(), h, c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20366
SetMinute
train
func (c *Carbon) SetMinute(m int) { c.Time = time.Date(c.Year(), c.Month(), c.Day(), c.Hour(), m, c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20367
SetSecond
train
func (c *Carbon) SetSecond(s int) { c.Time = time.Date(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), s, c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20368
SetDate
train
func (c *Carbon) SetDate(y int, m time.Month, d int) { c.Time = time.Date(y, m, d, c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20369
SetDateTime
train
func (c *Carbon) SetDateTime(y int, mon time.Month, d, h, m, s int) { c.Time = time.Date(y, mon, d, h, m, s, c.Nanosecond(), c.Location()) }
go
{ "resource": "" }
q20370
SetTimestamp
train
func (c *Carbon) SetTimestamp(sec int64) { c.Time = time.Unix(sec, 0).In(c.Location()) }
go
{ "resource": "" }
q20371
SetTimeZone
train
func (c *Carbon) SetTimeZone(name string) error { loc, err := time.LoadLocation(name) if err != nil { return err } c.Time = time.Date(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), loc) return nil }
go
{ "resource": "" }
q20372
IsWeekend
train
func (c *Carbon) IsWeekend() bool { d := c.Weekday() for _, wd := range c.WeekendDays() { if d == wd { return true } } return false }
go
{ "resource": "" }
q20373
IsYesterday
train
func (c *Carbon) IsYesterday() bool { n := Now().SubDay() return c.IsSameDay(n) }
go
{ "resource": "" }
q20374
IsTomorrow
train
func (c *Carbon) IsTomorrow() bool { n := Now().AddDay() return c.IsSameDay(n) }
go
{ "resource": "" }
q20375
IsLeapYear
train
func (c *Carbon) IsLeapYear() bool { y := c.Year() if (y%4 == 0 && y%100 != 0) || y%400 == 0 { return true } return false }
go
{ "resource": "" }
q20376
IsLongYear
train
func (c *Carbon) IsLongYear() bool { carb := create(c.Year(), time.December, 31, 0, 0, 0, 0, c.Location()) _, w := carb.WeekOfYear() return w == weeksPerLongYear }
go
{ "resource": "" }
q20377
IsSameAs
train
func (c *Carbon) IsSameAs(format string, carb *Carbon) bool { if carb == nil { return c.Format(DefaultFormat) == Now().Format(DefaultFormat) } return c.Format(DefaultFormat) == carb.Format(DefaultFormat) }
go
{ "resource": "" }
q20378
IsSameYear
train
func (c *Carbon) IsSameYear(carb *Carbon) bool { if carb == nil { return c.Year() == nowIn(c.Location()).Year() } return c.Year() == carb.Year() }
go
{ "resource": "" }
q20379
IsSameMonth
train
func (c *Carbon) IsSameMonth(carb *Carbon, sameYear bool) bool { m := nowIn(c.Location()).Month() if carb != nil { m = carb.Month() } if sameYear { return c.IsSameYear(carb) && c.Month() == m } return c.Month() == m }
go
{ "resource": "" }
q20380
IsSameDay
train
func (c *Carbon) IsSameDay(carb *Carbon) bool { n := nowIn(c.Location()) if carb != nil { n = carb } return c.Year() == n.Year() && c.Month() == n.Month() && c.Day() == n.Day() }
go
{ "resource": "" }
q20381
IsLastWeek
train
func (c *Carbon) IsLastWeek() bool { secondsInWeek := float64(secondsInWeek) difference := Now().Sub(c.Time) if difference.Seconds() > 0 && difference.Seconds() < secondsInWeek { return true } return false }
go
{ "resource": "" }
q20382
IsLastMonth
train
func (c *Carbon) IsLastMonth() bool { now := Now() monthDifference := now.Month() - c.Month() if absValue(true, int64(monthDifference)) != 1 { return false } if now.UnixNano() > c.UnixNano() && monthDifference == 1 { return true } return false }
go
{ "resource": "" }
q20383
Eq
train
func (c *Carbon) Eq(carb *Carbon) bool { return c.Equal(carb.Time) }
go
{ "resource": "" }
q20384
Closest
train
func (c *Carbon) Closest(a, b *Carbon) *Carbon { if c.DiffInSeconds(a, true) < c.DiffInSeconds(b, true) { return a } return b }
go
{ "resource": "" }
q20385
Farthest
train
func (c *Carbon) Farthest(a, b *Carbon) *Carbon { if c.DiffInSeconds(a, true) > c.DiffInSeconds(b, true) { return a } return b }
go
{ "resource": "" }
q20386
Min
train
func (c *Carbon) Min(carb *Carbon) *Carbon { if carb == nil { carb = nowIn(c.Location()) } if c.Lt(carb) { return c } return carb }
go
{ "resource": "" }
q20387
Max
train
func (c *Carbon) Max(carb *Carbon) *Carbon { if carb == nil { carb = nowIn(c.Location()) } if c.Gt(carb) { return c } return carb }
go
{ "resource": "" }
q20388
DiffInYears
train
func (c *Carbon) DiffInYears(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } if c.Year() == carb.Year() { return 0 } start := NewCarbon(c.Time) end := NewCarbon(carb.Time) if end.UnixNano() < start.UnixNano() { aux := start start = end end = aux } yearsAmmount := int6...
go
{ "resource": "" }
q20389
DiffInMonths
train
func (c *Carbon) DiffInMonths(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } cAux := c.Copy() carbAux := carb.Copy() if cAux.Location() != carbAux.Location() { cAux = NewCarbon(cAux.In(time.UTC)) carbAux = NewCarbon(carbAux.In(time.UTC)) } return calculateDiffInMonths(cAux,...
go
{ "resource": "" }
q20390
DiffDurationInString
train
func (c *Carbon) DiffDurationInString(carb *Carbon) string { if carb == nil { carb = nowIn(c.Location()) } return strings.Replace(carb.Sub(c.Time).String(), "-", "", 1) }
go
{ "resource": "" }
q20391
DiffInWeeks
train
func (c *Carbon) DiffInWeeks(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } return c.DiffInDays(carb, abs) / daysPerWeek }
go
{ "resource": "" }
q20392
DiffInDays
train
func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } return c.DiffInHours(carb, abs) / hoursPerDay }
go
{ "resource": "" }
q20393
DiffInNights
train
func (c *Carbon) DiffInNights(carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } return c.DiffInDays(carb, abs) }
go
{ "resource": "" }
q20394
DiffInDaysFiltered
train
func (c *Carbon) DiffInDaysFiltered(f Filter, carb *Carbon, abs bool) int64 { return c.DiffFiltered(dayDuration, f, carb, abs) }
go
{ "resource": "" }
q20395
DiffInHoursFiltered
train
func (c *Carbon) DiffInHoursFiltered(f Filter, carb *Carbon, abs bool) int64 { return c.DiffFiltered(time.Hour, f, carb, abs) }
go
{ "resource": "" }
q20396
DiffInWeekdays
train
func (c *Carbon) DiffInWeekdays(carb *Carbon, abs bool) int64 { f := func(t *Carbon) bool { return t.IsWeekday() } return c.DiffFiltered(dayDuration, f, carb, abs) }
go
{ "resource": "" }
q20397
DiffInWeekendDays
train
func (c *Carbon) DiffInWeekendDays(carb *Carbon, abs bool) int64 { f := func(t *Carbon) bool { return t.IsWeekend() } return c.DiffFiltered(dayDuration, f, carb, abs) }
go
{ "resource": "" }
q20398
DiffFiltered
train
func (c *Carbon) DiffFiltered(duration time.Duration, f Filter, carb *Carbon, abs bool) int64 { if carb == nil { carb = nowIn(c.Location()) } if c.IsSameDay(carb) { return 0 } inverse := false var counter int64 s := int64(duration.Seconds()) start, end := c.Copy(), carb.Copy() if start.Gt(end) { start, ...
go
{ "resource": "" }
q20399
DiffInHours
train
func (c *Carbon) DiffInHours(d *Carbon, abs bool) int64 { return c.DiffInMinutes(d, abs) / minutesPerHour }
go
{ "resource": "" }