id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,300 | klauspost/cpuid | private-gen.go | initRewrite | 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 | 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... | [
"func",
"initRewrite",
"(",
"rewriteRule",
"string",
")",
"rewrite",
"{",
"f",
":=",
"strings",
".",
"Split",
"(",
"rewriteRule",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"f",
")",
"!=",
"2",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr... | // Mostly copied from gofmt | [
"Mostly",
"copied",
"from",
"gofmt"
] | 05a8198c0f5a27739aec358908d7e12c64ce6eb7 | https://github.com/klauspost/cpuid/blob/05a8198c0f5a27739aec358908d7e12c64ce6eb7/private-gen.go#L196-L205 |
20,301 | klauspost/cpuid | private-gen.go | parseExpr | 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 | 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
} | [
"func",
"parseExpr",
"(",
"s",
",",
"what",
"string",
")",
"ast",
".",
"Expr",
"{",
"x",
",",
"err",
":=",
"parser",
".",
"ParseExpr",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintf",
"(",
"os",
".",
"Stderr",
",",
"\"... | // parseExpr parses s as an expression.
// It might make sense to expand this to allow statement patterns,
// but there are problems with preserving formatting and also
// with what a wildcard for a statement looks like. | [
"parseExpr",
"parses",
"s",
"as",
"an",
"expression",
".",
"It",
"might",
"make",
"sense",
"to",
"expand",
"this",
"to",
"allow",
"statement",
"patterns",
"but",
"there",
"are",
"problems",
"with",
"preserving",
"formatting",
"and",
"also",
"with",
"what",
"... | 05a8198c0f5a27739aec358908d7e12c64ce6eb7 | https://github.com/klauspost/cpuid/blob/05a8198c0f5a27739aec358908d7e12c64ce6eb7/private-gen.go#L211-L218 |
20,302 | klauspost/cpuid | private-gen.go | subst | 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 | 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... | [
"func",
"subst",
"(",
"m",
"map",
"[",
"string",
"]",
"reflect",
".",
"Value",
",",
"pattern",
"reflect",
".",
"Value",
",",
"pos",
"reflect",
".",
"Value",
")",
"reflect",
".",
"Value",
"{",
"if",
"!",
"pattern",
".",
"IsValid",
"(",
")",
"{",
"re... | // subst returns a copy of pattern with values from m substituted in place
// of wildcards and pos used as the position of tokens from the pattern.
// if m == nil, subst returns a copy of pattern and doesn't change the line
// number information. | [
"subst",
"returns",
"a",
"copy",
"of",
"pattern",
"with",
"values",
"from",
"m",
"substituted",
"in",
"place",
"of",
"wildcards",
"and",
"pos",
"used",
"as",
"the",
"position",
"of",
"tokens",
"from",
"the",
"pattern",
".",
"if",
"m",
"==",
"nil",
"subst... | 05a8198c0f5a27739aec358908d7e12c64ce6eb7 | https://github.com/klauspost/cpuid/blob/05a8198c0f5a27739aec358908d7e12c64ce6eb7/private-gen.go#L421-L476 |
20,303 | jawher/mow.cli | internal/matcher/option.go | NewOpt | func NewOpt(o *container.Container, index map[string]*container.Container) Matcher {
return &opt{
theOne: o,
index: index,
}
} | go | func NewOpt(o *container.Container, index map[string]*container.Container) Matcher {
return &opt{
theOne: o,
index: index,
}
} | [
"func",
"NewOpt",
"(",
"o",
"*",
"container",
".",
"Container",
",",
"index",
"map",
"[",
"string",
"]",
"*",
"container",
".",
"Container",
")",
"Matcher",
"{",
"return",
"&",
"opt",
"{",
"theOne",
":",
"o",
",",
"index",
":",
"index",
",",
"}",
"... | // NewOpt create an option matcher that can consume short and long options | [
"NewOpt",
"create",
"an",
"option",
"matcher",
"that",
"can",
"consume",
"short",
"and",
"long",
"options"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/matcher/option.go#L11-L16 |
20,304 | jawher/mow.cli | internal/matcher/context.go | NewParseContext | func NewParseContext() ParseContext {
return ParseContext{
Args: map[*container.Container][]string{},
Opts: map[*container.Container][]string{},
ExcludedOpts: map[*container.Container]struct{}{},
RejectOptions: false,
}
} | go | func NewParseContext() ParseContext {
return ParseContext{
Args: map[*container.Container][]string{},
Opts: map[*container.Container][]string{},
ExcludedOpts: map[*container.Container]struct{}{},
RejectOptions: false,
}
} | [
"func",
"NewParseContext",
"(",
")",
"ParseContext",
"{",
"return",
"ParseContext",
"{",
"Args",
":",
"map",
"[",
"*",
"container",
".",
"Container",
"]",
"[",
"]",
"string",
"{",
"}",
",",
"Opts",
":",
"map",
"[",
"*",
"container",
".",
"Container",
"... | // NewParseContext create a new ParseContext | [
"NewParseContext",
"create",
"a",
"new",
"ParseContext"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/matcher/context.go#L14-L21 |
20,305 | jawher/mow.cli | internal/matcher/context.go | Merge | 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 | 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...)
}
} | [
"func",
"(",
"pc",
"ParseContext",
")",
"Merge",
"(",
"o",
"ParseContext",
")",
"{",
"for",
"k",
",",
"vs",
":=",
"range",
"o",
".",
"Args",
"{",
"pc",
".",
"Args",
"[",
"k",
"]",
"=",
"append",
"(",
"pc",
".",
"Args",
"[",
"k",
"]",
",",
"vs... | // Merge adds the values in the provided context in the current context | [
"Merge",
"adds",
"the",
"values",
"in",
"the",
"provided",
"context",
"in",
"the",
"current",
"context"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/matcher/context.go#L24-L32 |
20,306 | jawher/mow.cli | internal/fsm/fsm.go | T | func (s *State) T(matcher matcher.Matcher, next *State) *State {
s.Transitions = append(s.Transitions, &Transition{Matcher: matcher, Next: next})
return next
} | go | func (s *State) T(matcher matcher.Matcher, next *State) *State {
s.Transitions = append(s.Transitions, &Transition{Matcher: matcher, Next: next})
return next
} | [
"func",
"(",
"s",
"*",
"State",
")",
"T",
"(",
"matcher",
"matcher",
".",
"Matcher",
",",
"next",
"*",
"State",
")",
"*",
"State",
"{",
"s",
".",
"Transitions",
"=",
"append",
"(",
"s",
".",
"Transitions",
",",
"&",
"Transition",
"{",
"Matcher",
":... | // T creates a transition between 2 states | [
"T",
"creates",
"a",
"transition",
"between",
"2",
"states"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/fsm/fsm.go#L48-L51 |
20,307 | jawher/mow.cli | internal/fsm/fsm.go | Prepare | func (s *State) Prepare() {
simplify(s, s, map[*State]bool{})
sortTransitions(s, map[*State]bool{})
} | go | func (s *State) Prepare() {
simplify(s, s, map[*State]bool{})
sortTransitions(s, map[*State]bool{})
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Prepare",
"(",
")",
"{",
"simplify",
"(",
"s",
",",
"s",
",",
"map",
"[",
"*",
"State",
"]",
"bool",
"{",
"}",
")",
"\n",
"sortTransitions",
"(",
"s",
",",
"map",
"[",
"*",
"State",
"]",
"bool",
"{",
"}",... | // Prepare simplifies the FSM and sorts the transitions according to their priorities | [
"Prepare",
"simplifies",
"the",
"FSM",
"and",
"sorts",
"the",
"transitions",
"according",
"to",
"their",
"priorities"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/fsm/fsm.go#L54-L57 |
20,308 | jawher/mow.cli | internal/fsm/fsm.go | Parse | 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 | 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)
} | [
"func",
"(",
"s",
"*",
"State",
")",
"Parse",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"pc",
":=",
"matcher",
".",
"NewParseContext",
"(",
")",
"\n",
"ok",
":=",
"s",
".",
"apply",
"(",
"args",
",",
"pc",
")",
"\n",
"if",
"!",
"ok",
... | // Parse tries to navigate into the FSM according to the provided args | [
"Parse",
"tries",
"to",
"navigate",
"into",
"the",
"FSM",
"according",
"to",
"the",
"provided",
"args"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/fsm/fsm.go#L120-L132 |
20,309 | jawher/mow.cli | internal/values/utils.go | IsBool | func IsBool(v flag.Value) bool {
if bf, ok := v.(BoolValued); ok {
return bf.IsBoolFlag()
}
return false
} | go | func IsBool(v flag.Value) bool {
if bf, ok := v.(BoolValued); ok {
return bf.IsBoolFlag()
}
return false
} | [
"func",
"IsBool",
"(",
"v",
"flag",
".",
"Value",
")",
"bool",
"{",
"if",
"bf",
",",
"ok",
":=",
"v",
".",
"(",
"BoolValued",
")",
";",
"ok",
"{",
"return",
"bf",
".",
"IsBoolFlag",
"(",
")",
"\n",
"}",
"\n\n",
"return",
"false",
"\n",
"}"
] | // IsBool checks if a given value is a bool value, i.e. implements the BoolValued interface | [
"IsBool",
"checks",
"if",
"a",
"given",
"value",
"is",
"a",
"bool",
"value",
"i",
".",
"e",
".",
"implements",
"the",
"BoolValued",
"interface"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/utils.go#L10-L16 |
20,310 | jawher/mow.cli | internal/values/utils.go | SetFromEnv | 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 | 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... | [
"func",
"SetFromEnv",
"(",
"into",
"flag",
".",
"Value",
",",
"envVars",
"string",
")",
"bool",
"{",
"multiValued",
",",
"isMulti",
":=",
"into",
".",
"(",
"MultiValued",
")",
"\n\n",
"if",
"len",
"(",
"envVars",
")",
">",
"0",
"{",
"for",
"_",
",",
... | // SetFromEnv fills a value from a list of env vars | [
"SetFromEnv",
"fills",
"a",
"value",
"from",
"a",
"list",
"of",
"env",
"vars"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/utils.go#L19-L42 |
20,311 | jawher/mow.cli | internal/parser/parser.go | Parse | 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 | 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()
} | [
"func",
"Parse",
"(",
"tokens",
"[",
"]",
"*",
"lexer",
".",
"Token",
",",
"params",
"Params",
")",
"(",
"*",
"fsm",
".",
"State",
",",
"error",
")",
"{",
"p",
":=",
"&",
"parser",
"{",
"spec",
":",
"params",
".",
"Spec",
",",
"options",
":",
"... | // Parse transforms a slice of tokens into an FSM or returns an ParseError | [
"Parse",
"transforms",
"a",
"slice",
"of",
"tokens",
"into",
"an",
"FSM",
"or",
"returns",
"an",
"ParseError"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/parser/parser.go#L22-L32 |
20,312 | jawher/mow.cli | internal/fsm/fsmdot/fsmdot.go | Dot | 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 | 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"))
} | [
"func",
"Dot",
"(",
"s",
"*",
"fsm",
".",
"State",
")",
"string",
"{",
"trs",
":=",
"dot",
"(",
"s",
",",
"mkStateNames",
"(",
")",
",",
"map",
"[",
"*",
"fsm",
".",
"State",
"]",
"struct",
"{",
"}",
"{",
"}",
")",
"\n",
"return",
"fmt",
".",... | // Dot generates a graphviz dot representation of an FSM | [
"Dot",
"generates",
"a",
"graphviz",
"dot",
"representation",
"of",
"an",
"FSM"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/fsm/fsmdot/fsmdot.go#L11-L14 |
20,313 | jawher/mow.cli | internal/values/values.go | NewBool | func NewBool(into *bool, v bool) *BoolValue {
*into = v
return (*BoolValue)(into)
} | go | func NewBool(into *bool, v bool) *BoolValue {
*into = v
return (*BoolValue)(into)
} | [
"func",
"NewBool",
"(",
"into",
"*",
"bool",
",",
"v",
"bool",
")",
"*",
"BoolValue",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"BoolValue",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewBool creates a new bool value | [
"NewBool",
"creates",
"a",
"new",
"bool",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L43-L46 |
20,314 | jawher/mow.cli | internal/values/values.go | NewString | func NewString(into *string, v string) *StringValue {
*into = v
return (*StringValue)(into)
} | go | func NewString(into *string, v string) *StringValue {
*into = v
return (*StringValue)(into)
} | [
"func",
"NewString",
"(",
"into",
"*",
"string",
",",
"v",
"string",
")",
"*",
"StringValue",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"StringValue",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewString creates a new string value | [
"NewString",
"creates",
"a",
"new",
"string",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L85-L88 |
20,315 | jawher/mow.cli | internal/values/values.go | NewInt | func NewInt(into *int, v int) *IntValue {
*into = v
return (*IntValue)(into)
} | go | func NewInt(into *int, v int) *IntValue {
*into = v
return (*IntValue)(into)
} | [
"func",
"NewInt",
"(",
"into",
"*",
"int",
",",
"v",
"int",
")",
"*",
"IntValue",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"IntValue",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewInt creates a new int value | [
"NewInt",
"creates",
"a",
"new",
"int",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L117-L120 |
20,316 | jawher/mow.cli | internal/values/values.go | NewFloat64 | func NewFloat64(into *float64, v float64) *Float64Value {
*into = v
return (*Float64Value)(into)
} | go | func NewFloat64(into *float64, v float64) *Float64Value {
*into = v
return (*Float64Value)(into)
} | [
"func",
"NewFloat64",
"(",
"into",
"*",
"float64",
",",
"v",
"float64",
")",
"*",
"Float64Value",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"Float64Value",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewFloat64 creates a new int value | [
"NewFloat64",
"creates",
"a",
"new",
"int",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L148-L151 |
20,317 | jawher/mow.cli | internal/values/values.go | NewStrings | func NewStrings(into *[]string, v []string) *StringsValue {
*into = v
return (*StringsValue)(into)
} | go | func NewStrings(into *[]string, v []string) *StringsValue {
*into = v
return (*StringsValue)(into)
} | [
"func",
"NewStrings",
"(",
"into",
"*",
"[",
"]",
"string",
",",
"v",
"[",
"]",
"string",
")",
"*",
"StringsValue",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"StringsValue",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewStrings creates a new multi-string value | [
"NewStrings",
"creates",
"a",
"new",
"multi",
"-",
"string",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L181-L184 |
20,318 | jawher/mow.cli | internal/values/values.go | NewInts | func NewInts(into *[]int, v []int) *IntsValue {
*into = v
return (*IntsValue)(into)
} | go | func NewInts(into *[]int, v []int) *IntsValue {
*into = v
return (*IntsValue)(into)
} | [
"func",
"NewInts",
"(",
"into",
"*",
"[",
"]",
"int",
",",
"v",
"[",
"]",
"int",
")",
"*",
"IntsValue",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"IntsValue",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewInts creates a new multi-int value | [
"NewInts",
"creates",
"a",
"new",
"multi",
"-",
"int",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L227-L230 |
20,319 | jawher/mow.cli | internal/values/values.go | NewFloats64 | func NewFloats64(into *[]float64, v []float64) *Floats64Value {
*into = v
return (*Floats64Value)(into)
} | go | func NewFloats64(into *[]float64, v []float64) *Floats64Value {
*into = v
return (*Floats64Value)(into)
} | [
"func",
"NewFloats64",
"(",
"into",
"*",
"[",
"]",
"float64",
",",
"v",
"[",
"]",
"float64",
")",
"*",
"Floats64Value",
"{",
"*",
"into",
"=",
"v",
"\n",
"return",
"(",
"*",
"Floats64Value",
")",
"(",
"into",
")",
"\n",
"}"
] | // NewFloats64 creates a new multi-int value | [
"NewFloats64",
"creates",
"a",
"new",
"multi",
"-",
"int",
"value"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/values/values.go#L277-L280 |
20,320 | jawher/mow.cli | internal/matcher/options.go | NewOptions | func NewOptions(opts []*container.Container, index map[string]*container.Container) Matcher {
return &options{
options: opts,
index: index,
}
} | go | func NewOptions(opts []*container.Container, index map[string]*container.Container) Matcher {
return &options{
options: opts,
index: index,
}
} | [
"func",
"NewOptions",
"(",
"opts",
"[",
"]",
"*",
"container",
".",
"Container",
",",
"index",
"map",
"[",
"string",
"]",
"*",
"container",
".",
"Container",
")",
"Matcher",
"{",
"return",
"&",
"options",
"{",
"options",
":",
"opts",
",",
"index",
":",... | // NewOptions create an Options matcher which can parse a group of options | [
"NewOptions",
"create",
"an",
"Options",
"matcher",
"which",
"can",
"parse",
"a",
"group",
"of",
"options"
] | 483c839d919a98fbaf913bffe1f5135302b423c9 | https://github.com/jawher/mow.cli/blob/483c839d919a98fbaf913bffe1f5135302b423c9/internal/matcher/options.go#L10-L15 |
20,321 | UnnoTed/fileb0x | dir/dir.go | Exists | func (d *Dir) Exists(newDir string) bool {
for _, dir := range d.Blacklist {
if dir == newDir {
return true
}
}
return false
} | go | func (d *Dir) Exists(newDir string) bool {
for _, dir := range d.Blacklist {
if dir == newDir {
return true
}
}
return false
} | [
"func",
"(",
"d",
"*",
"Dir",
")",
"Exists",
"(",
"newDir",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"dir",
":=",
"range",
"d",
".",
"Blacklist",
"{",
"if",
"dir",
"==",
"newDir",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",... | // Exists checks if a directory exists or not | [
"Exists",
"checks",
"if",
"a",
"directory",
"exists",
"or",
"not"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/dir/dir.go#L12-L20 |
20,322 | UnnoTed/fileb0x | dir/dir.go | Parse | 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 | 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]
... | [
"func",
"(",
"d",
"*",
"Dir",
")",
"Parse",
"(",
"newDir",
"string",
")",
"[",
"]",
"string",
"{",
"list",
":=",
"strings",
".",
"Split",
"(",
"newDir",
",",
"\"",
"\"",
")",
"\n\n",
"var",
"dirWalk",
"[",
"]",
"string",
"\n\n",
"for",
"indx",
":... | // Parse a directory to build a list of directories to be made at b0x.go | [
"Parse",
"a",
"directory",
"to",
"build",
"a",
"list",
"of",
"directories",
"to",
"be",
"made",
"at",
"b0x",
".",
"go"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/dir/dir.go#L23-L45 |
20,323 | UnnoTed/fileb0x | dir/dir.go | Insert | 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 | func (d *Dir) Insert(newDir string) {
if !d.Exists(newDir) {
d.Blacklist = append(d.Blacklist, newDir)
d.List = append(d.List, d.Parse(newDir))
}
} | [
"func",
"(",
"d",
"*",
"Dir",
")",
"Insert",
"(",
"newDir",
"string",
")",
"{",
"if",
"!",
"d",
".",
"Exists",
"(",
"newDir",
")",
"{",
"d",
".",
"Blacklist",
"=",
"append",
"(",
"d",
".",
"Blacklist",
",",
"newDir",
")",
"\n",
"d",
".",
"List"... | // Insert a new folder to the list | [
"Insert",
"a",
"new",
"folder",
"to",
"the",
"list"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/dir/dir.go#L48-L53 |
20,324 | UnnoTed/fileb0x | updater/updater.go | Get | 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 | 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)
... | [
"func",
"(",
"up",
"*",
"Updater",
")",
"Get",
"(",
")",
"error",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"up",
".",
"Server",
",",
"nil",
")",
"\n",
"i... | // Get gets the list of file hash from the server | [
"Get",
"gets",
"the",
"list",
"of",
"file",
"hash",
"from",
"the",
"server"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/updater/updater.go#L70-L115 |
20,325 | UnnoTed/fileb0x | updater/updater.go | Updatable | 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 | 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.... | [
"func",
"(",
"up",
"*",
"Updater",
")",
"Updatable",
"(",
"files",
"map",
"[",
"string",
"]",
"*",
"file",
".",
"File",
")",
"(",
"bool",
",",
"error",
")",
"{",
"hasUpdates",
":=",
"!",
"up",
".",
"EqualHashes",
"(",
"files",
")",
"\n\n",
"if",
... | // Updatable checks if there is any file that should be updaTed | [
"Updatable",
"checks",
"if",
"there",
"is",
"any",
"file",
"that",
"should",
"be",
"updaTed"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/updater/updater.go#L118-L132 |
20,326 | UnnoTed/fileb0x | updater/updater.go | EqualHashes | 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 | 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... | [
"func",
"(",
"up",
"*",
"Updater",
")",
"EqualHashes",
"(",
"files",
"map",
"[",
"string",
"]",
"*",
"file",
".",
"File",
")",
"bool",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"files",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
",",
"f",
"."... | // EqualHashes builds the list of local hashes before
// checking if there is any that should be updated | [
"EqualHashes",
"builds",
"the",
"list",
"of",
"local",
"hashes",
"before",
"checking",
"if",
"there",
"is",
"any",
"that",
"should",
"be",
"updated"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/updater/updater.go#L155-L203 |
20,327 | UnnoTed/fileb0x | updater/updater.go | UpdateFiles | 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 | 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... | [
"func",
"(",
"up",
"*",
"Updater",
")",
"UpdateFiles",
"(",
"files",
"map",
"[",
"string",
"]",
"*",
"file",
".",
"File",
")",
"error",
"{",
"updatable",
",",
"err",
":=",
"up",
".",
"Updatable",
"(",
"files",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // UpdateFiles sends all files that should be updated to the server
// the limit is 3 concurrent files at once | [
"UpdateFiles",
"sends",
"all",
"files",
"that",
"should",
"be",
"updated",
"to",
"the",
"server",
"the",
"limit",
"is",
"3",
"concurrent",
"files",
"at",
"once"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/updater/updater.go#L213-L296 |
20,328 | UnnoTed/fileb0x | template/template.go | Set | 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 | 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
} | [
"func",
"(",
"t",
"*",
"Template",
")",
"Set",
"(",
"name",
"string",
")",
"error",
"{",
"t",
".",
"name",
"=",
"name",
"\n",
"if",
"name",
"!=",
"\"",
"\"",
"&&",
"name",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"`Error: Templ... | // Set the template to be used
// "files" or "file" | [
"Set",
"the",
"template",
"to",
"be",
"used",
"files",
"or",
"file"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/template/template.go#L19-L32 |
20,329 | UnnoTed/fileb0x | template/template.go | Exec | 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 | 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
} | [
"func",
"(",
"t",
"*",
"Template",
")",
"Exec",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"tmpl",
",",
"err",
":=",
"template",
".",
"New",
"(",
"t",
".",
"name",
")",
".",
"Funcs",
"(",
"funcsTemplate",
")",
".",
"Parse",
"(",
... | // Exec the template and return the final data as byte array | [
"Exec",
"the",
"template",
"and",
"return",
"the",
"final",
"data",
"as",
"byte",
"array"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/template/template.go#L35-L49 |
20,330 | UnnoTed/fileb0x | config/config.go | Defaults | 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 | 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... | [
"func",
"(",
"cfg",
"*",
"Config",
")",
"Defaults",
"(",
")",
"error",
"{",
"// default destination",
"if",
"cfg",
".",
"Dest",
"==",
"\"",
"\"",
"{",
"cfg",
".",
"Dest",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
"// insert \"/\" at end of dest when it's not found... | // Defaults set the default value for some variables | [
"Defaults",
"set",
"the",
"default",
"value",
"for",
"some",
"variables"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/config/config.go#L34-L75 |
20,331 | UnnoTed/fileb0x | config/file.go | Parse | 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 | 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... | [
"func",
"(",
"f",
"*",
"File",
")",
"Parse",
"(",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"// remove comments",
"f",
".",
"RemoveJSONComments",
"(",
")",
"\n\n",
"to",
":=",
"&",
"Config",
"{",
"}",
"\n",
"switch",
"f",
".",
"Mode",
"{",
... | // Parse gets the config file's content from File.Data | [
"Parse",
"gets",
"the",
"config",
"file",
"s",
"content",
"from",
"File",
".",
"Data"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/config/file.go#L74-L89 |
20,332 | UnnoTed/fileb0x | config/file.go | RemoveJSONComments | func (f *File) RemoveJSONComments() {
if f.Mode == "json" {
// remove inline comments
f.Data = []byte(regexComments.ReplaceAllString(string(f.Data), ""))
}
} | go | func (f *File) RemoveJSONComments() {
if f.Mode == "json" {
// remove inline comments
f.Data = []byte(regexComments.ReplaceAllString(string(f.Data), ""))
}
} | [
"func",
"(",
"f",
"*",
"File",
")",
"RemoveJSONComments",
"(",
")",
"{",
"if",
"f",
".",
"Mode",
"==",
"\"",
"\"",
"{",
"// remove inline comments",
"f",
".",
"Data",
"=",
"[",
"]",
"byte",
"(",
"regexComments",
".",
"ReplaceAllString",
"(",
"string",
... | // RemoveJSONComments from the file | [
"RemoveJSONComments",
"from",
"the",
"file"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/config/file.go#L110-L115 |
20,333 | UnnoTed/fileb0x | compression/gzip.go | NewGzip | func NewGzip() *Gzip {
gz := new(Gzip)
gz.Options = new(Options)
return gz
} | go | func NewGzip() *Gzip {
gz := new(Gzip)
gz.Options = new(Options)
return gz
} | [
"func",
"NewGzip",
"(",
")",
"*",
"Gzip",
"{",
"gz",
":=",
"new",
"(",
"Gzip",
")",
"\n",
"gz",
".",
"Options",
"=",
"new",
"(",
"Options",
")",
"\n",
"return",
"gz",
"\n",
"}"
] | // NewGzip creates a Gzip + Options variable | [
"NewGzip",
"creates",
"a",
"Gzip",
"+",
"Options",
"variable"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/compression/gzip.go#L15-L19 |
20,334 | UnnoTed/fileb0x | compression/gzip.go | Compress | 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 | 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... | [
"func",
"(",
"gz",
"*",
"Gzip",
")",
"Compress",
"(",
"content",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"!",
"gz",
".",
"Options",
".",
"Compress",
"{",
"return",
"content",
",",
"nil",
"\n",
"}",
"\n\n",
"/... | // Compress to gzip | [
"Compress",
"to",
"gzip"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/compression/gzip.go#L22-L64 |
20,335 | UnnoTed/fileb0x | utils/utils.go | GetCurrentDir | func GetCurrentDir() (string, error) {
d, err := filepath.Abs(filepath.Dir(os.Args[0]))
return d, err
} | go | func GetCurrentDir() (string, error) {
d, err := filepath.Abs(filepath.Dir(os.Args[0]))
return d, err
} | [
"func",
"GetCurrentDir",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"filepath",
".",
"Dir",
"(",
"os",
".",
"Args",
"[",
"0",
"]",
")",
")",
"\n",
"return",
"d",
",",
"err",
"\n",
"}"
] | // GetCurrentDir gets the directory where the application was run | [
"GetCurrentDir",
"gets",
"the",
"directory",
"where",
"the",
"application",
"was",
"run"
] | 88e9138aed91f822e323232092bcde0399796db3 | https://github.com/UnnoTed/fileb0x/blob/88e9138aed91f822e323232092bcde0399796db3/utils/utils.go#L26-L29 |
20,336 | uniplaces/carbon | carbon.go | NewCarbon | 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 | 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(),
}
} | [
"func",
"NewCarbon",
"(",
"t",
"time",
".",
"Time",
")",
"*",
"Carbon",
"{",
"wds",
":=",
"[",
"]",
"time",
".",
"Weekday",
"{",
"time",
".",
"Saturday",
",",
"time",
".",
"Sunday",
",",
"}",
"\n",
"return",
"&",
"Carbon",
"{",
"Time",
":",
"t",
... | // NewCarbon returns a pointer to a new Carbon instance | [
"NewCarbon",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"Carbon",
"instance"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L76-L89 |
20,337 | uniplaces/carbon | carbon.go | After | 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 | 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)
} | [
"func",
"After",
"(",
"d",
"time",
".",
"Duration",
")",
"<-",
"chan",
"time",
".",
"Time",
"{",
"if",
"isTimeFrozen",
"{",
"currentFrozenTime",
"=",
"currentFrozenTime",
".",
"Add",
"(",
"d",
")",
"\n",
"c",
":=",
"make",
"(",
"chan",
"time",
".",
"... | // After will be behave like time.After unless time has been frozen
// If time is frozen it will add the expected delay and immediately send the frozen time on the returned channel | [
"After",
"will",
"be",
"behave",
"like",
"time",
".",
"After",
"unless",
"time",
"has",
"been",
"frozen",
"If",
"time",
"is",
"frozen",
"it",
"will",
"add",
"the",
"expected",
"delay",
"and",
"immediately",
"send",
"the",
"frozen",
"time",
"on",
"the",
"... | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L109-L118 |
20,338 | uniplaces/carbon | carbon.go | Sleep | func Sleep(d time.Duration) {
if isTimeFrozen && d > 0 {
currentFrozenTime = currentFrozenTime.Add(d)
return
}
time.Sleep(d)
} | go | func Sleep(d time.Duration) {
if isTimeFrozen && d > 0 {
currentFrozenTime = currentFrozenTime.Add(d)
return
}
time.Sleep(d)
} | [
"func",
"Sleep",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"if",
"isTimeFrozen",
"&&",
"d",
">",
"0",
"{",
"currentFrozenTime",
"=",
"currentFrozenTime",
".",
"Add",
"(",
"d",
")",
"\n\n",
"return",
"\n",
"}",
"\n\n",
"time",
".",
"Sleep",
"(",
"d... | // Sleep will be behave like time.Sleep unless time has been frozen
// If time is frozen it will add the expected sleep delay and return immediately | [
"Sleep",
"will",
"be",
"behave",
"like",
"time",
".",
"Sleep",
"unless",
"time",
"has",
"been",
"frozen",
"If",
"time",
"is",
"frozen",
"it",
"will",
"add",
"the",
"expected",
"sleep",
"delay",
"and",
"return",
"immediately"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L139-L147 |
20,339 | uniplaces/carbon | carbon.go | create | 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 | 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))
} | [
"func",
"create",
"(",
"y",
"int",
",",
"mon",
"time",
".",
"Month",
",",
"d",
",",
"h",
",",
"m",
",",
"s",
",",
"ns",
"int",
",",
"l",
"*",
"time",
".",
"Location",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"time",
".",
"Date",
"... | // create returns a new carbon pointe. It is a helper function to create new dates | [
"create",
"returns",
"a",
"new",
"carbon",
"pointe",
".",
"It",
"is",
"a",
"helper",
"function",
"to",
"create",
"new",
"dates"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L150-L152 |
20,340 | uniplaces/carbon | carbon.go | Create | 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 | 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
} | [
"func",
"Create",
"(",
"y",
"int",
",",
"mon",
"time",
".",
"Month",
",",
"d",
",",
"h",
",",
"m",
",",
"s",
",",
"ns",
"int",
",",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"time",
".",
"... | // Create returns a new pointer to Carbon instance from a specific date and time.
// If the location is invalid, it returns an error instead. | [
"Create",
"returns",
"a",
"new",
"pointer",
"to",
"Carbon",
"instance",
"from",
"a",
"specific",
"date",
"and",
"time",
".",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L156-L162 |
20,341 | uniplaces/carbon | carbon.go | CreateFromTime | 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 | 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)
} | [
"func",
"CreateFromTime",
"(",
"h",
",",
"m",
",",
"s",
",",
"ns",
"int",
",",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"y",
",",
"mon",
",",
"d",
":=",
"Now",
"(",
")",
".",
"Date",
"(",
")",
"\n\n",
"return",
"... | // CreateFromTime returns a new pointer to a Carbon instance from just a date.
// The time portion is set to now.
// If the locations is invalid, it returns an error instead. | [
"CreateFromTime",
"returns",
"a",
"new",
"pointer",
"to",
"a",
"Carbon",
"instance",
"from",
"just",
"a",
"date",
".",
"The",
"time",
"portion",
"is",
"set",
"to",
"now",
".",
"If",
"the",
"locations",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"in... | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L177-L181 |
20,342 | uniplaces/carbon | carbon.go | CreateFromFormat | 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 | 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
} | [
"func",
"CreateFromFormat",
"(",
"layout",
",",
"value",
"string",
",",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"time",
".",
"LoadLocation",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // CreateFromFormat returns a new pointer to a Carbon instance from a specific format.
// If the location is invalid, it returns an error instead. | [
"CreateFromFormat",
"returns",
"a",
"new",
"pointer",
"to",
"a",
"Carbon",
"instance",
"from",
"a",
"specific",
"format",
".",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L185-L196 |
20,343 | uniplaces/carbon | carbon.go | CreateFromTimestamp | 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 | 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
} | [
"func",
"CreateFromTimestamp",
"(",
"timestamp",
"int64",
",",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"time",
".",
"LoadLocation",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return... | // CreateFromTimestamp returns a new pointer to a Carbon instance from a timestamp.
// If the location is invalid, it returns an error instead. | [
"CreateFromTimestamp",
"returns",
"a",
"new",
"pointer",
"to",
"a",
"Carbon",
"instance",
"from",
"a",
"timestamp",
".",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L200-L209 |
20,344 | uniplaces/carbon | carbon.go | CreateFromMonthAndYear | 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 | 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)
} | [
"func",
"CreateFromMonthAndYear",
"(",
"y",
"int",
",",
"mon",
"time",
".",
"Month",
",",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"_",
",",
"_",
",",
"d",
":=",
"Now",
"(",
")",
".",
"Date",
"(",
")",
"\n",
"h",
"... | // CreateFromMonthAndYear returns a new pointer to a Carbon instance from a specific month and year.
// If the location is invalid, it returns an error instead. | [
"CreateFromMonthAndYear",
"returns",
"a",
"new",
"pointer",
"to",
"a",
"Carbon",
"instance",
"from",
"a",
"specific",
"month",
"and",
"year",
".",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L219-L225 |
20,345 | uniplaces/carbon | carbon.go | Today | func Today(location string) (*Carbon, error) {
l, err := time.LoadLocation(location)
if err != nil {
return nil, err
}
return NewCarbon(Now().In(l)), err
} | go | func Today(location string) (*Carbon, error) {
l, err := time.LoadLocation(location)
if err != nil {
return nil, err
}
return NewCarbon(Now().In(l)), err
} | [
"func",
"Today",
"(",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"time",
".",
"LoadLocation",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\... | // Today returns a pointer to a new carbon instance for today
// If the location is invalid, it returns an error instead. | [
"Today",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"carbon",
"instance",
"for",
"today",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L244-L251 |
20,346 | uniplaces/carbon | carbon.go | Tomorrow | func Tomorrow(location string) (*Carbon, error) {
c, err := Today(location)
if err != nil {
return nil, err
}
return c.AddDay(), nil
} | go | func Tomorrow(location string) (*Carbon, error) {
c, err := Today(location)
if err != nil {
return nil, err
}
return c.AddDay(), nil
} | [
"func",
"Tomorrow",
"(",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"Today",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
"... | // Tomorrow returns a pointer to a new carbon instance for tomorrow
// If the location is invalid, it returns an error instead. | [
"Tomorrow",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"carbon",
"instance",
"for",
"tomorrow",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L255-L262 |
20,347 | uniplaces/carbon | carbon.go | Yesterday | func Yesterday(location string) (*Carbon, error) {
c, err := Today(location)
if err != nil {
return nil, err
}
return c.SubDay(), nil
} | go | func Yesterday(location string) (*Carbon, error) {
c, err := Today(location)
if err != nil {
return nil, err
}
return c.SubDay(), nil
} | [
"func",
"Yesterday",
"(",
"location",
"string",
")",
"(",
"*",
"Carbon",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"Today",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"return",
... | // Yesterday returns a pointer to a new carbon instance for yesterday
// If the location is invalid, it returns an error instead. | [
"Yesterday",
"returns",
"a",
"pointer",
"to",
"a",
"new",
"carbon",
"instance",
"for",
"yesterday",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L266-L273 |
20,348 | uniplaces/carbon | carbon.go | Copy | func (c *Carbon) Copy() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location())
} | go | func (c *Carbon) Copy() *Carbon {
return create(c.Year(), c.Month(), c.Day(), c.Hour(), c.Minute(), c.Second(), c.Nanosecond(), c.Location())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Copy",
"(",
")",
"*",
"Carbon",
"{",
"return",
"create",
"(",
"c",
".",
"Year",
"(",
")",
",",
"c",
".",
"Month",
"(",
")",
",",
"c",
".",
"Day",
"(",
")",
",",
"c",
".",
"Hour",
"(",
")",
",",
"c",
... | // Copy returns a new copy of the current Carbon instance | [
"Copy",
"returns",
"a",
"new",
"copy",
"of",
"the",
"current",
"Carbon",
"instance"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L314-L316 |
20,349 | uniplaces/carbon | carbon.go | Quarter | 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 | 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
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Quarter",
"(",
")",
"int",
"{",
"month",
":=",
"c",
".",
"Month",
"(",
")",
"\n",
"switch",
"{",
"case",
"month",
"<",
"4",
":",
"return",
"1",
"\n",
"case",
"month",
">=",
"4",
"&&",
"month",
"<",
"7",
... | // Quarter gets the current quarter | [
"Quarter",
"gets",
"the",
"current",
"quarter"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L334-L345 |
20,350 | uniplaces/carbon | carbon.go | WeekOfMonth | func (c *Carbon) WeekOfMonth() int {
w := math.Ceil(float64(c.Day() / daysPerWeek))
return int(w + 1)
} | go | func (c *Carbon) WeekOfMonth() int {
w := math.Ceil(float64(c.Day() / daysPerWeek))
return int(w + 1)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"WeekOfMonth",
"(",
")",
"int",
"{",
"w",
":=",
"math",
".",
"Ceil",
"(",
"float64",
"(",
"c",
".",
"Day",
"(",
")",
"/",
"daysPerWeek",
")",
")",
"\n",
"return",
"int",
"(",
"w",
"+",
"1",
")",
"\n",
"}"... | // WeekOfMonth returns the week of the month | [
"WeekOfMonth",
"returns",
"the",
"week",
"of",
"the",
"month"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L367-L370 |
20,351 | uniplaces/carbon | carbon.go | AddYears | func (c *Carbon) AddYears(y int) *Carbon {
return NewCarbon(c.AddDate(y, 0, 0))
} | go | func (c *Carbon) AddYears(y int) *Carbon {
return NewCarbon(c.AddDate(y, 0, 0))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddYears",
"(",
"y",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"y",
",",
"0",
",",
"0",
")",
")",
"\n",
"}"
] | // AddYears adds a year to the current time.
// Positive values travel forward while negative values travel into the past | [
"AddYears",
"adds",
"a",
"year",
"to",
"the",
"current",
"time",
".",
"Positive",
"values",
"travel",
"forward",
"while",
"negative",
"values",
"travel",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L395-L397 |
20,352 | uniplaces/carbon | carbon.go | AddQuarters | func (c *Carbon) AddQuarters(q int) *Carbon {
return NewCarbon(c.AddDate(0, monthsPerQuarter*q, 0))
} | go | func (c *Carbon) AddQuarters(q int) *Carbon {
return NewCarbon(c.AddDate(0, monthsPerQuarter*q, 0))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddQuarters",
"(",
"q",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"0",
",",
"monthsPerQuarter",
"*",
"q",
",",
"0",
")",
")",
"\n",
"}"
] | // AddQuarters adds quarters to the current time.
// Positive values travel forward while negative values travel into the past | [
"AddQuarters",
"adds",
"quarters",
"to",
"the",
"current",
"time",
".",
"Positive",
"values",
"travel",
"forward",
"while",
"negative",
"values",
"travel",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L406-L408 |
20,353 | uniplaces/carbon | carbon.go | AddCenturies | func (c *Carbon) AddCenturies(cent int) *Carbon {
return NewCarbon(c.AddDate(yearsPerCenturies*cent, 0, 0))
} | go | func (c *Carbon) AddCenturies(cent int) *Carbon {
return NewCarbon(c.AddDate(yearsPerCenturies*cent, 0, 0))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddCenturies",
"(",
"cent",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"yearsPerCenturies",
"*",
"cent",
",",
"0",
",",
"0",
")",
")",
"\n",
"}"
] | // AddCenturies adds centuries to the time.
// Positive values travels forward while negative values travels into the past | [
"AddCenturies",
"adds",
"centuries",
"to",
"the",
"time",
".",
"Positive",
"values",
"travels",
"forward",
"while",
"negative",
"values",
"travels",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L417-L419 |
20,354 | uniplaces/carbon | carbon.go | AddMonths | func (c *Carbon) AddMonths(m int) *Carbon {
return NewCarbon(c.AddDate(0, m, 0))
} | go | func (c *Carbon) AddMonths(m int) *Carbon {
return NewCarbon(c.AddDate(0, m, 0))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddMonths",
"(",
"m",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"0",
",",
"m",
",",
"0",
")",
")",
"\n",
"}"
] | // AddMonths adds months to the current time.
// Positive value travels forward while negative values travels into the past | [
"AddMonths",
"adds",
"months",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"values",
"travels",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L428-L430 |
20,355 | uniplaces/carbon | carbon.go | AddSeconds | func (c *Carbon) AddSeconds(s int) *Carbon {
d := time.Duration(s) * time.Second
return NewCarbon(c.Add(d))
} | go | func (c *Carbon) AddSeconds(s int) *Carbon {
d := time.Duration(s) * time.Second
return NewCarbon(c.Add(d))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddSeconds",
"(",
"s",
"int",
")",
"*",
"Carbon",
"{",
"d",
":=",
"time",
".",
"Duration",
"(",
"s",
")",
"*",
"time",
".",
"Second",
"\n",
"return",
"NewCarbon",
"(",
"c",
".",
"Add",
"(",
"d",
")",
")",
... | // AddSeconds adds seconds to the current time.
// Positive values travels forward while negative values travels into the past. | [
"AddSeconds",
"adds",
"seconds",
"to",
"the",
"current",
"time",
".",
"Positive",
"values",
"travels",
"forward",
"while",
"negative",
"values",
"travels",
"into",
"the",
"past",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L439-L442 |
20,356 | uniplaces/carbon | carbon.go | AddDays | func (c *Carbon) AddDays(d int) *Carbon {
return NewCarbon(c.AddDate(0, 0, d))
} | go | func (c *Carbon) AddDays(d int) *Carbon {
return NewCarbon(c.AddDate(0, 0, d))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddDays",
"(",
"d",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"d",
")",
")",
"\n",
"}"
] | // AddDays adds a day to the current time.
// Positive value travels forward while negative value travels into the past | [
"AddDays",
"adds",
"a",
"day",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"value",
"travels",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L451-L453 |
20,357 | uniplaces/carbon | carbon.go | AddWeekdays | 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 | 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
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddWeekdays",
"(",
"wd",
"int",
")",
"*",
"Carbon",
"{",
"d",
":=",
"1",
"\n",
"if",
"wd",
"<",
"0",
"{",
"wd",
",",
"d",
"=",
"-",
"wd",
",",
"-",
"d",
"\n",
"}",
"\n",
"t",
":=",
"c",
".",
"Copy",
... | // AddWeekdays adds a weekday to the current time.
// Positive value travels forward while negative value travels into the past | [
"AddWeekdays",
"adds",
"a",
"weekday",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"value",
"travels",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L462-L476 |
20,358 | uniplaces/carbon | carbon.go | AddWeeks | func (c *Carbon) AddWeeks(w int) *Carbon {
return NewCarbon(c.AddDate(0, 0, daysPerWeek*w))
} | go | func (c *Carbon) AddWeeks(w int) *Carbon {
return NewCarbon(c.AddDate(0, 0, daysPerWeek*w))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddWeeks",
"(",
"w",
"int",
")",
"*",
"Carbon",
"{",
"return",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"daysPerWeek",
"*",
"w",
")",
")",
"\n",
"}"
] | // AddWeeks adds a week to the current time.
// Positive value travels forward while negative value travels into the past. | [
"AddWeeks",
"adds",
"a",
"week",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"value",
"travels",
"into",
"the",
"past",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L485-L487 |
20,359 | uniplaces/carbon | carbon.go | AddHours | func (c *Carbon) AddHours(h int) *Carbon {
d := time.Duration(h) * time.Hour
return NewCarbon(c.Add(d))
} | go | func (c *Carbon) AddHours(h int) *Carbon {
d := time.Duration(h) * time.Hour
return NewCarbon(c.Add(d))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddHours",
"(",
"h",
"int",
")",
"*",
"Carbon",
"{",
"d",
":=",
"time",
".",
"Duration",
"(",
"h",
")",
"*",
"time",
".",
"Hour",
"\n\n",
"return",
"NewCarbon",
"(",
"c",
".",
"Add",
"(",
"d",
")",
")",
... | // AddHours adds an hour to the current time.
// Positive value travels forward while negative value travels into the past | [
"AddHours",
"adds",
"an",
"hour",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"value",
"travels",
"into",
"the",
"past"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L496-L500 |
20,360 | uniplaces/carbon | carbon.go | AddMonthsNoOverflow | 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 | func (c *Carbon) AddMonthsNoOverflow(m int) *Carbon {
addedDate := NewCarbon(c.AddDate(0, m, 0))
if c.Day() != addedDate.Day() {
return addedDate.PreviousMonthLastDay()
}
return addedDate
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddMonthsNoOverflow",
"(",
"m",
"int",
")",
"*",
"Carbon",
"{",
"addedDate",
":=",
"NewCarbon",
"(",
"c",
".",
"AddDate",
"(",
"0",
",",
"m",
",",
"0",
")",
")",
"\n",
"if",
"c",
".",
"Day",
"(",
")",
"!="... | // AddMonthsNoOverflow adds a month to the current time, not overflowing in case the
// destination month has less days than the current one.
// Positive value travels forward while negative value travels into the past. | [
"AddMonthsNoOverflow",
"adds",
"a",
"month",
"to",
"the",
"current",
"time",
"not",
"overflowing",
"in",
"case",
"the",
"destination",
"month",
"has",
"less",
"days",
"than",
"the",
"current",
"one",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"ne... | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L510-L517 |
20,361 | uniplaces/carbon | carbon.go | AddMinutes | func (c *Carbon) AddMinutes(m int) *Carbon {
d := time.Duration(m) * time.Minute
return NewCarbon(c.Add(d))
} | go | func (c *Carbon) AddMinutes(m int) *Carbon {
d := time.Duration(m) * time.Minute
return NewCarbon(c.Add(d))
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"AddMinutes",
"(",
"m",
"int",
")",
"*",
"Carbon",
"{",
"d",
":=",
"time",
".",
"Duration",
"(",
"m",
")",
"*",
"time",
".",
"Minute",
"\n\n",
"return",
"NewCarbon",
"(",
"c",
".",
"Add",
"(",
"d",
")",
")"... | // AddMinutes adds minutes to the current time.
// Positive value travels forward while negative value travels into the past. | [
"AddMinutes",
"adds",
"minutes",
"to",
"the",
"current",
"time",
".",
"Positive",
"value",
"travels",
"forward",
"while",
"negative",
"value",
"travels",
"into",
"the",
"past",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L531-L535 |
20,362 | uniplaces/carbon | carbon.go | SetYear | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetYear",
"(",
"y",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"y",
",",
"c",
".",
"Month",
"(",
")",
",",
"c",
".",
"Day",
"(",
")",
",",
"c",
".",
"Hour",
"(",
")",
",",
"c... | // SetYear sets the year of the current time | [
"SetYear",
"sets",
"the",
"year",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L653-L655 |
20,363 | uniplaces/carbon | carbon.go | SetMonth | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetMonth",
"(",
"m",
"time",
".",
"Month",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"c",
".",
"Year",
"(",
")",
",",
"m",
",",
"c",
".",
"Day",
"(",
")",
",",
"c",
".",
"Hour",
"(",... | // SetMonth sets the month of the current time | [
"SetMonth",
"sets",
"the",
"month",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L658-L660 |
20,364 | uniplaces/carbon | carbon.go | SetDay | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetDay",
"(",
"d",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"c",
".",
"Year",
"(",
")",
",",
"c",
".",
"Month",
"(",
")",
",",
"d",
",",
"c",
".",
"Hour",
"(",
")",
",",
"c... | // SetDay sets the day of the current time | [
"SetDay",
"sets",
"the",
"day",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L663-L665 |
20,365 | uniplaces/carbon | carbon.go | SetHour | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetHour",
"(",
"h",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"c",
".",
"Year",
"(",
")",
",",
"c",
".",
"Month",
"(",
")",
",",
"c",
".",
"Day",
"(",
")",
",",
"h",
",",
"c... | // SetHour sets the hour of the current time | [
"SetHour",
"sets",
"the",
"hour",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L668-L670 |
20,366 | uniplaces/carbon | carbon.go | SetMinute | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetMinute",
"(",
"m",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"c",
".",
"Year",
"(",
")",
",",
"c",
".",
"Month",
"(",
")",
",",
"c",
".",
"Day",
"(",
")",
",",
"c",
".",
... | // SetMinute sets the minute of the current time | [
"SetMinute",
"sets",
"the",
"minute",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L673-L675 |
20,367 | uniplaces/carbon | carbon.go | SetSecond | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetSecond",
"(",
"s",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"c",
".",
"Year",
"(",
")",
",",
"c",
".",
"Month",
"(",
")",
",",
"c",
".",
"Day",
"(",
")",
",",
"c",
".",
... | // SetSecond sets the second of the current time | [
"SetSecond",
"sets",
"the",
"second",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L678-L680 |
20,368 | uniplaces/carbon | carbon.go | SetDate | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetDate",
"(",
"y",
"int",
",",
"m",
"time",
".",
"Month",
",",
"d",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
"c",
".",
"Hour",
"(",
")",
",",
... | // SetDate sets only the date of the current time | [
"SetDate",
"sets",
"only",
"the",
"date",
"of",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L683-L685 |
20,369 | uniplaces/carbon | carbon.go | SetDateTime | 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 | 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())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetDateTime",
"(",
"y",
"int",
",",
"mon",
"time",
".",
"Month",
",",
"d",
",",
"h",
",",
"m",
",",
"s",
"int",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Date",
"(",
"y",
",",
"mon",
",",
"d",
"... | // SetDateTime sets the date and the time | [
"SetDateTime",
"sets",
"the",
"date",
"and",
"the",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L688-L690 |
20,370 | uniplaces/carbon | carbon.go | SetTimestamp | func (c *Carbon) SetTimestamp(sec int64) {
c.Time = time.Unix(sec, 0).In(c.Location())
} | go | func (c *Carbon) SetTimestamp(sec int64) {
c.Time = time.Unix(sec, 0).In(c.Location())
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetTimestamp",
"(",
"sec",
"int64",
")",
"{",
"c",
".",
"Time",
"=",
"time",
".",
"Unix",
"(",
"sec",
",",
"0",
")",
".",
"In",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}"
] | // SetTimestamp sets the current time given a timestamp | [
"SetTimestamp",
"sets",
"the",
"current",
"time",
"given",
"a",
"timestamp"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L739-L741 |
20,371 | uniplaces/carbon | carbon.go | SetTimeZone | 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 | 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
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"SetTimeZone",
"(",
"name",
"string",
")",
"error",
"{",
"loc",
",",
"err",
":=",
"time",
".",
"LoadLocation",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"c",
"."... | // SetTimeZone sets the location from a string
// If the location is invalid, it returns an error instead. | [
"SetTimeZone",
"sets",
"the",
"location",
"from",
"a",
"string",
"If",
"the",
"location",
"is",
"invalid",
"it",
"returns",
"an",
"error",
"instead",
"."
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L745-L753 |
20,372 | uniplaces/carbon | carbon.go | IsWeekend | func (c *Carbon) IsWeekend() bool {
d := c.Weekday()
for _, wd := range c.WeekendDays() {
if d == wd {
return true
}
}
return false
} | go | func (c *Carbon) IsWeekend() bool {
d := c.Weekday()
for _, wd := range c.WeekendDays() {
if d == wd {
return true
}
}
return false
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsWeekend",
"(",
")",
"bool",
"{",
"d",
":=",
"c",
".",
"Weekday",
"(",
")",
"\n",
"for",
"_",
",",
"wd",
":=",
"range",
"c",
".",
"WeekendDays",
"(",
")",
"{",
"if",
"d",
"==",
"wd",
"{",
"return",
"tru... | // IsWeekend determines if the current time is a weekend day | [
"IsWeekend",
"determines",
"if",
"the",
"current",
"time",
"is",
"a",
"weekend",
"day"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L851-L860 |
20,373 | uniplaces/carbon | carbon.go | IsYesterday | func (c *Carbon) IsYesterday() bool {
n := Now().SubDay()
return c.IsSameDay(n)
} | go | func (c *Carbon) IsYesterday() bool {
n := Now().SubDay()
return c.IsSameDay(n)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsYesterday",
"(",
")",
"bool",
"{",
"n",
":=",
"Now",
"(",
")",
".",
"SubDay",
"(",
")",
"\n\n",
"return",
"c",
".",
"IsSameDay",
"(",
"n",
")",
"\n",
"}"
] | // IsYesterday determines if the current time is yesterday | [
"IsYesterday",
"determines",
"if",
"the",
"current",
"time",
"is",
"yesterday"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L863-L867 |
20,374 | uniplaces/carbon | carbon.go | IsTomorrow | func (c *Carbon) IsTomorrow() bool {
n := Now().AddDay()
return c.IsSameDay(n)
} | go | func (c *Carbon) IsTomorrow() bool {
n := Now().AddDay()
return c.IsSameDay(n)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsTomorrow",
"(",
")",
"bool",
"{",
"n",
":=",
"Now",
"(",
")",
".",
"AddDay",
"(",
")",
"\n\n",
"return",
"c",
".",
"IsSameDay",
"(",
"n",
")",
"\n",
"}"
] | // IsTomorrow determines if the current time is tomorrow | [
"IsTomorrow",
"determines",
"if",
"the",
"current",
"time",
"is",
"tomorrow"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L875-L879 |
20,375 | uniplaces/carbon | carbon.go | IsLeapYear | func (c *Carbon) IsLeapYear() bool {
y := c.Year()
if (y%4 == 0 && y%100 != 0) || y%400 == 0 {
return true
}
return false
} | go | func (c *Carbon) IsLeapYear() bool {
y := c.Year()
if (y%4 == 0 && y%100 != 0) || y%400 == 0 {
return true
}
return false
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsLeapYear",
"(",
")",
"bool",
"{",
"y",
":=",
"c",
".",
"Year",
"(",
")",
"\n",
"if",
"(",
"y",
"%",
"4",
"==",
"0",
"&&",
"y",
"%",
"100",
"!=",
"0",
")",
"||",
"y",
"%",
"400",
"==",
"0",
"{",
"... | // IsLeapYear determines if current current time is a leap year | [
"IsLeapYear",
"determines",
"if",
"current",
"current",
"time",
"is",
"a",
"leap",
"year"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L892-L899 |
20,376 | uniplaces/carbon | carbon.go | IsLongYear | 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 | func (c *Carbon) IsLongYear() bool {
carb := create(c.Year(), time.December, 31, 0, 0, 0, 0, c.Location())
_, w := carb.WeekOfYear()
return w == weeksPerLongYear
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsLongYear",
"(",
")",
"bool",
"{",
"carb",
":=",
"create",
"(",
"c",
".",
"Year",
"(",
")",
",",
"time",
".",
"December",
",",
"31",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"c",
".",
"Location",
... | // IsLongYear determines if the instance is a long year | [
"IsLongYear",
"determines",
"if",
"the",
"instance",
"is",
"a",
"long",
"year"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L902-L907 |
20,377 | uniplaces/carbon | carbon.go | IsSameAs | 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 | 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)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsSameAs",
"(",
"format",
"string",
",",
"carb",
"*",
"Carbon",
")",
"bool",
"{",
"if",
"carb",
"==",
"nil",
"{",
"return",
"c",
".",
"Format",
"(",
"DefaultFormat",
")",
"==",
"Now",
"(",
")",
".",
"Format",
... | // IsSameAs compares the formatted values of the two dates.
// If passed date is nil, compares against today | [
"IsSameAs",
"compares",
"the",
"formatted",
"values",
"of",
"the",
"two",
"dates",
".",
"If",
"passed",
"date",
"is",
"nil",
"compares",
"against",
"today"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L911-L917 |
20,378 | uniplaces/carbon | carbon.go | IsSameYear | func (c *Carbon) IsSameYear(carb *Carbon) bool {
if carb == nil {
return c.Year() == nowIn(c.Location()).Year()
}
return c.Year() == carb.Year()
} | go | func (c *Carbon) IsSameYear(carb *Carbon) bool {
if carb == nil {
return c.Year() == nowIn(c.Location()).Year()
}
return c.Year() == carb.Year()
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsSameYear",
"(",
"carb",
"*",
"Carbon",
")",
"bool",
"{",
"if",
"carb",
"==",
"nil",
"{",
"return",
"c",
".",
"Year",
"(",
")",
"==",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
".",
"Year",
"(",
... | // IsSameYear checks if the passed in date is in the same year as the current time year.
// If passed date is nil, compares against today | [
"IsSameYear",
"checks",
"if",
"the",
"passed",
"in",
"date",
"is",
"in",
"the",
"same",
"year",
"as",
"the",
"current",
"time",
"year",
".",
"If",
"passed",
"date",
"is",
"nil",
"compares",
"against",
"today"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L926-L932 |
20,379 | uniplaces/carbon | carbon.go | IsSameMonth | 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 | 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
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsSameMonth",
"(",
"carb",
"*",
"Carbon",
",",
"sameYear",
"bool",
")",
"bool",
"{",
"m",
":=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
".",
"Month",
"(",
")",
"\n",
"if",
"carb",
"!=",
"nil",
"... | // IsSameMonth checks if the passed in date is in the same month as the current month
// If passed date is nil, compares against today | [
"IsSameMonth",
"checks",
"if",
"the",
"passed",
"in",
"date",
"is",
"in",
"the",
"same",
"month",
"as",
"the",
"current",
"month",
"If",
"passed",
"date",
"is",
"nil",
"compares",
"against",
"today"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L941-L951 |
20,380 | uniplaces/carbon | carbon.go | IsSameDay | 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 | 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()
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsSameDay",
"(",
"carb",
"*",
"Carbon",
")",
"bool",
"{",
"n",
":=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"if",
"carb",
"!=",
"nil",
"{",
"n",
"=",
"carb",
"\n",
"}",
"\n\n",
"return",
... | // IsSameDay checks if the passed in date is the same day as the current day.
// If passed date is nil, compares against today | [
"IsSameDay",
"checks",
"if",
"the",
"passed",
"in",
"date",
"is",
"the",
"same",
"day",
"as",
"the",
"current",
"day",
".",
"If",
"passed",
"date",
"is",
"nil",
"compares",
"against",
"today"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L955-L962 |
20,381 | uniplaces/carbon | carbon.go | IsLastWeek | 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 | func (c *Carbon) IsLastWeek() bool {
secondsInWeek := float64(secondsInWeek)
difference := Now().Sub(c.Time)
if difference.Seconds() > 0 && difference.Seconds() < secondsInWeek {
return true
}
return false
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsLastWeek",
"(",
")",
"bool",
"{",
"secondsInWeek",
":=",
"float64",
"(",
"secondsInWeek",
")",
"\n",
"difference",
":=",
"Now",
"(",
")",
".",
"Sub",
"(",
"c",
".",
"Time",
")",
"\n",
"if",
"difference",
".",
... | // IsLastWeek returns true is the date is within last week | [
"IsLastWeek",
"returns",
"true",
"is",
"the",
"date",
"is",
"within",
"last",
"week"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1000-L1008 |
20,382 | uniplaces/carbon | carbon.go | IsLastMonth | 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 | 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
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"IsLastMonth",
"(",
")",
"bool",
"{",
"now",
":=",
"Now",
"(",
")",
"\n\n",
"monthDifference",
":=",
"now",
".",
"Month",
"(",
")",
"-",
"c",
".",
"Month",
"(",
")",
"\n\n",
"if",
"absValue",
"(",
"true",
","... | // IsLastMonth returns true is the date is within last month | [
"IsLastMonth",
"returns",
"true",
"is",
"the",
"date",
"is",
"within",
"last",
"month"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1011-L1025 |
20,383 | uniplaces/carbon | carbon.go | Eq | func (c *Carbon) Eq(carb *Carbon) bool {
return c.Equal(carb.Time)
} | go | func (c *Carbon) Eq(carb *Carbon) bool {
return c.Equal(carb.Time)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Eq",
"(",
"carb",
"*",
"Carbon",
")",
"bool",
"{",
"return",
"c",
".",
"Equal",
"(",
"carb",
".",
"Time",
")",
"\n",
"}"
] | // Eq determines if the current carbon is equal to another | [
"Eq",
"determines",
"if",
"the",
"current",
"carbon",
"is",
"equal",
"to",
"another"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1028-L1030 |
20,384 | uniplaces/carbon | carbon.go | Closest | func (c *Carbon) Closest(a, b *Carbon) *Carbon {
if c.DiffInSeconds(a, true) < c.DiffInSeconds(b, true) {
return a
}
return b
} | go | func (c *Carbon) Closest(a, b *Carbon) *Carbon {
if c.DiffInSeconds(a, true) < c.DiffInSeconds(b, true) {
return a
}
return b
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Closest",
"(",
"a",
",",
"b",
"*",
"Carbon",
")",
"*",
"Carbon",
"{",
"if",
"c",
".",
"DiffInSeconds",
"(",
"a",
",",
"true",
")",
"<",
"c",
".",
"DiffInSeconds",
"(",
"b",
",",
"true",
")",
"{",
"return",... | // Closest returns the closest date from the current time | [
"Closest",
"returns",
"the",
"closest",
"date",
"from",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1101-L1107 |
20,385 | uniplaces/carbon | carbon.go | Farthest | func (c *Carbon) Farthest(a, b *Carbon) *Carbon {
if c.DiffInSeconds(a, true) > c.DiffInSeconds(b, true) {
return a
}
return b
} | go | func (c *Carbon) Farthest(a, b *Carbon) *Carbon {
if c.DiffInSeconds(a, true) > c.DiffInSeconds(b, true) {
return a
}
return b
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Farthest",
"(",
"a",
",",
"b",
"*",
"Carbon",
")",
"*",
"Carbon",
"{",
"if",
"c",
".",
"DiffInSeconds",
"(",
"a",
",",
"true",
")",
">",
"c",
".",
"DiffInSeconds",
"(",
"b",
",",
"true",
")",
"{",
"return"... | // Farthest returns the farthest date from the current time | [
"Farthest",
"returns",
"the",
"farthest",
"date",
"from",
"the",
"current",
"time"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1110-L1116 |
20,386 | uniplaces/carbon | carbon.go | Min | func (c *Carbon) Min(carb *Carbon) *Carbon {
if carb == nil {
carb = nowIn(c.Location())
}
if c.Lt(carb) {
return c
}
return carb
} | go | func (c *Carbon) Min(carb *Carbon) *Carbon {
if carb == nil {
carb = nowIn(c.Location())
}
if c.Lt(carb) {
return c
}
return carb
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Min",
"(",
"carb",
"*",
"Carbon",
")",
"*",
"Carbon",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"c",
".",
"Lt",
"(",
"c... | // Min returns the minimum instance between a given instance and the current instance | [
"Min",
"returns",
"the",
"minimum",
"instance",
"between",
"a",
"given",
"instance",
"and",
"the",
"current",
"instance"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1119-L1128 |
20,387 | uniplaces/carbon | carbon.go | Max | func (c *Carbon) Max(carb *Carbon) *Carbon {
if carb == nil {
carb = nowIn(c.Location())
}
if c.Gt(carb) {
return c
}
return carb
} | go | func (c *Carbon) Max(carb *Carbon) *Carbon {
if carb == nil {
carb = nowIn(c.Location())
}
if c.Gt(carb) {
return c
}
return carb
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"Max",
"(",
"carb",
"*",
"Carbon",
")",
"*",
"Carbon",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"c",
".",
"Gt",
"(",
... | // Max returns the maximum instance between a given instance and the current instance | [
"Max",
"returns",
"the",
"maximum",
"instance",
"between",
"a",
"given",
"instance",
"and",
"the",
"current",
"instance"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1136-L1146 |
20,388 | uniplaces/carbon | carbon.go | DiffInYears | 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 | 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... | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInYears",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n\n",
"if",
"c"... | // DiffInYears returns the difference in years | [
"DiffInYears",
"returns",
"the",
"difference",
"in",
"years"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1154-L1180 |
20,389 | uniplaces/carbon | carbon.go | DiffInMonths | 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 | 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,... | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInMonths",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n\n",
"cAux",
... | // DiffInMonths returns the difference in months | [
"DiffInMonths",
"returns",
"the",
"difference",
"in",
"months"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1183-L1196 |
20,390 | uniplaces/carbon | carbon.go | DiffDurationInString | func (c *Carbon) DiffDurationInString(carb *Carbon) string {
if carb == nil {
carb = nowIn(c.Location())
}
return strings.Replace(carb.Sub(c.Time).String(), "-", "", 1)
} | go | func (c *Carbon) DiffDurationInString(carb *Carbon) string {
if carb == nil {
carb = nowIn(c.Location())
}
return strings.Replace(carb.Sub(c.Time).String(), "-", "", 1)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffDurationInString",
"(",
"carb",
"*",
"Carbon",
")",
"string",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n\n",
"return",
"strings",
".... | // DiffDurationInString returns the duration difference in string format | [
"DiffDurationInString",
"returns",
"the",
"duration",
"difference",
"in",
"string",
"format"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1254-L1260 |
20,391 | uniplaces/carbon | carbon.go | DiffInWeeks | func (c *Carbon) DiffInWeeks(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInDays(carb, abs) / daysPerWeek
} | go | func (c *Carbon) DiffInWeeks(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInDays(carb, abs) / daysPerWeek
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInWeeks",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"... | // DiffInWeeks returns the difference in weeks | [
"DiffInWeeks",
"returns",
"the",
"difference",
"in",
"weeks"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1263-L1268 |
20,392 | uniplaces/carbon | carbon.go | DiffInDays | func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInHours(carb, abs) / hoursPerDay
} | go | func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInHours(carb, abs) / hoursPerDay
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInDays",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"c... | // DiffInDays returns the difference in days | [
"DiffInDays",
"returns",
"the",
"difference",
"in",
"days"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1271-L1276 |
20,393 | uniplaces/carbon | carbon.go | DiffInNights | func (c *Carbon) DiffInNights(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInDays(carb, abs)
} | go | func (c *Carbon) DiffInNights(carb *Carbon, abs bool) int64 {
if carb == nil {
carb = nowIn(c.Location())
}
return c.DiffInDays(carb, abs)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInNights",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
".",
"Location",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
... | // DiffInNights returns the difference in nights | [
"DiffInNights",
"returns",
"the",
"difference",
"in",
"nights"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1279-L1284 |
20,394 | uniplaces/carbon | carbon.go | DiffInDaysFiltered | func (c *Carbon) DiffInDaysFiltered(f Filter, carb *Carbon, abs bool) int64 {
return c.DiffFiltered(dayDuration, f, carb, abs)
} | go | func (c *Carbon) DiffInDaysFiltered(f Filter, carb *Carbon, abs bool) int64 {
return c.DiffFiltered(dayDuration, f, carb, abs)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInDaysFiltered",
"(",
"f",
"Filter",
",",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"return",
"c",
".",
"DiffFiltered",
"(",
"dayDuration",
",",
"f",
",",
"carb",
",",
"abs",
")",
"\n",
... | // DiffInDaysFiltered returns the difference in days using a filter | [
"DiffInDaysFiltered",
"returns",
"the",
"difference",
"in",
"days",
"using",
"a",
"filter"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1293-L1295 |
20,395 | uniplaces/carbon | carbon.go | DiffInHoursFiltered | func (c *Carbon) DiffInHoursFiltered(f Filter, carb *Carbon, abs bool) int64 {
return c.DiffFiltered(time.Hour, f, carb, abs)
} | go | func (c *Carbon) DiffInHoursFiltered(f Filter, carb *Carbon, abs bool) int64 {
return c.DiffFiltered(time.Hour, f, carb, abs)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInHoursFiltered",
"(",
"f",
"Filter",
",",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"return",
"c",
".",
"DiffFiltered",
"(",
"time",
".",
"Hour",
",",
"f",
",",
"carb",
",",
"abs",
")"... | // DiffInHoursFiltered returns the difference in hours using a filter | [
"DiffInHoursFiltered",
"returns",
"the",
"difference",
"in",
"hours",
"using",
"a",
"filter"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1298-L1300 |
20,396 | uniplaces/carbon | carbon.go | DiffInWeekdays | 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 | func (c *Carbon) DiffInWeekdays(carb *Carbon, abs bool) int64 {
f := func(t *Carbon) bool {
return t.IsWeekday()
}
return c.DiffFiltered(dayDuration, f, carb, abs)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInWeekdays",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Carbon",
")",
"bool",
"{",
"return",
"t",
".",
"IsWeekday",
"(",
")",
"\n",
"}",
"\n\n",... | // DiffInWeekdays returns the difference in weekdays | [
"DiffInWeekdays",
"returns",
"the",
"difference",
"in",
"weekdays"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1303-L1309 |
20,397 | uniplaces/carbon | carbon.go | DiffInWeekendDays | 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 | func (c *Carbon) DiffInWeekendDays(carb *Carbon, abs bool) int64 {
f := func(t *Carbon) bool {
return t.IsWeekend()
}
return c.DiffFiltered(dayDuration, f, carb, abs)
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInWeekendDays",
"(",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"f",
":=",
"func",
"(",
"t",
"*",
"Carbon",
")",
"bool",
"{",
"return",
"t",
".",
"IsWeekend",
"(",
")",
"\n",
"}",
"\n\... | // DiffInWeekendDays returns the difference in weekend days using a filter | [
"DiffInWeekendDays",
"returns",
"the",
"difference",
"in",
"weekend",
"days",
"using",
"a",
"filter"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1312-L1318 |
20,398 | uniplaces/carbon | carbon.go | DiffFiltered | 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 | 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, ... | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffFiltered",
"(",
"duration",
"time",
".",
"Duration",
",",
"f",
"Filter",
",",
"carb",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"if",
"carb",
"==",
"nil",
"{",
"carb",
"=",
"nowIn",
"(",
"c",
... | // DiffFiltered returns the difference by the given duration using a filter | [
"DiffFiltered",
"returns",
"the",
"difference",
"by",
"the",
"given",
"duration",
"using",
"a",
"filter"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1321-L1348 |
20,399 | uniplaces/carbon | carbon.go | DiffInHours | func (c *Carbon) DiffInHours(d *Carbon, abs bool) int64 {
return c.DiffInMinutes(d, abs) / minutesPerHour
} | go | func (c *Carbon) DiffInHours(d *Carbon, abs bool) int64 {
return c.DiffInMinutes(d, abs) / minutesPerHour
} | [
"func",
"(",
"c",
"*",
"Carbon",
")",
"DiffInHours",
"(",
"d",
"*",
"Carbon",
",",
"abs",
"bool",
")",
"int64",
"{",
"return",
"c",
".",
"DiffInMinutes",
"(",
"d",
",",
"abs",
")",
"/",
"minutesPerHour",
"\n",
"}"
] | // DiffInHours returns the difference in hours | [
"DiffInHours",
"returns",
"the",
"difference",
"in",
"hours"
] | 223a8652664c690cc91a950eba4cbbc579defb71 | https://github.com/uniplaces/carbon/blob/223a8652664c690cc91a950eba4cbbc579defb71/carbon.go#L1351-L1353 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.