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