-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathoption.go
47 lines (38 loc) · 1.19 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package timeago
type opt string
const (
// OptUpcoming option removes the suffix "ago" when the date is
// in the future. This option is enabled by default, there
// is no need to pass it. It's available to keep backward
// compatibility with the previous versions.
OptUpcoming opt = "upcoming"
// Upcoming option displays "OptOnline" if date interval withing
// the OnlineThreshold provided in config. By default, it's
// 60 seconds. For example instead of "13 seconds ago" it will
// print "Online".
OptOnline opt = "online"
// OptJustNow option displays "Just now" if date interval withing
// the JustNowThreshold provided in config. By default, it's
// 60 seconds. For example instead of "32 seconds ago" it will
// print "Just now".
OptJustNow opt = "justNow"
// OptNoSuffix option removes suffix from datetime result and get
// for example "5 minutes" instead of "5 minutes ago".
OptNoSuffix opt = "noSuffix"
)
func enableOption(o opt) {
options = append(options, o)
}
func enableOptions(opts []opt) {
for _, opt := range opts {
enableOption(opt)
}
}
func optionIsEnabled(o opt) bool {
for _, option := range options {
if option == o {
return true
}
}
return false
}