Passed
Push — v3.0.0 ( 4b7c3c...3f6295 )
by Serhii
01:23
created

timeago.Config.IsLocationProvided   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
nop 0
1
package timeago
2
3
type Config struct {
4
	// Language is an ISO 639 language code like en, ru, de, nl, etc.
5
	// If Language is not set it will default to English "en".
6
	Language string
7
8
	// Location is the timezone location neeed for parsing
9
	// string date like "2019-01-01 00:00:00" to time.Time.
10
	// If Location is not set it will default to the server's.
11
	// Example: "America/New_York", "Asia/China"
12
	Location string
13
14
	// Translations is a slice of language sets that can be used to
15
	// overwrite the default translations. Read more about it in the docs
16
	// https://time-ago.github.io/configurations.html#overwrite-translations
17
	Translations []LangSet
18
}
19
20
// NewConfig creates a new Config instance with the given language, location
21
// and language sets to overwrite the default translations.
22
func NewConfig(lang, loc string, langSets []LangSet) *Config {
23
	return &Config{
24
		Language:     lang,
25
		Location:     loc,
26
		Translations: langSets,
27
	}
28
}
29
30
// IsLocationProvided check if the location is privided by the user
31
func (c Config) IsLocationProvided() bool {
32
	return c.Location != ""
33
}
34