@@ -105,24 +105,36 @@ func fetchInfo(ctfTimeUrl string, info *CTFTimeInfo) {
105
105
}
106
106
107
107
func showInfo (info * CTFTimeInfo ) {
108
- fmt .Printf (theme .ColorGray + "title: " + theme .ColorBlue + "%s" + theme .ColorReset + "\n " , info .Title )
109
-
110
108
now := time .Now ()
111
109
112
- fmt .Printf (theme .ColorGray + "start: " + theme .ColorGreen + "%v " + theme .ColorGray + "finish: " + theme .ColorRed + "%v" + theme .ColorReset + "\n " , info .Start , info .Finish )
113
-
114
110
started := info .Start .Before (now )
115
111
finished := info .Finish .Before (now )
116
112
ongoing := started && ! finished
117
113
114
+ fmt .Printf (theme .ColorGray + "title: " + theme .ColorBlue + "%s" + theme .ColorReset + " " , info .Title )
115
+
118
116
if ongoing {
119
117
fmt .Printf (theme .ColorGray + "time remaining: " + theme .ColorReset + "%v\n " , info .Finish .Sub (now ))
120
118
} else if finished {
121
119
fmt .Printf (theme .ColorGray + "time since finish: " + theme .ColorReset + "%v\n " , info .Finish .Sub (now ))
122
120
} else {
123
- fmt .Printf (theme .ColorGray + "time to start: " + theme .ColorReset + "%v\n " , info .Start .Sub (now ))
124
- fmt .Printf (theme .ColorGray + "time to finish: " + theme .ColorReset + "%v\n " , info .Finish .Sub (now ))
121
+ delta := info .Start .Sub (now )
122
+
123
+ hours := int (delta .Hours ())
124
+ mins := int (delta .Minutes ())
125
+ seconds := int (delta .Seconds ())
126
+
127
+ if hours > 0 {
128
+ fmt .Printf (theme .ColorGray + "starts in " + theme .ColorPurple + "~%v" + theme .ColorGray + " hours\n " , hours )
129
+ } else if mins > 0 {
130
+ fmt .Printf (theme .ColorGray + "starts in " + theme .ColorPurple + "~%v" + theme .ColorGray + " mins\n " , mins )
131
+ } else {
132
+ fmt .Printf (theme .ColorGray + "starts in " + theme .ColorPurple + "~%v" + theme .ColorGray + " seconds\n " , seconds )
133
+ }
125
134
}
135
+
136
+ fmt .Printf (theme .ColorGray + "start: " + theme .ColorGreen + "%v" + theme .ColorReset + "\n " , info .Start .Local ())
137
+ fmt .Printf (theme .ColorGray + "finish: " + theme .ColorRed + "%v" + theme .ColorReset + "\n " , info .Finish .Local ())
126
138
}
127
139
128
140
func CtfTime (args []string ) {
@@ -161,7 +173,7 @@ func CtfTime(args []string) {
161
173
fmt .Printf ("\r " )
162
174
163
175
for idx , ctfTimeUrl := range config .CtfTimeUrls {
164
- fmt .Printf (theme .ColorGray + "url: " + theme .ColorReset + "%v" + theme .ColorReset + "\n " , ctfTimeUrl )
176
+ fmt .Printf (theme .ColorGray + "url: " + theme .ColorCyan + theme . StartUnderline + "%v" + theme .ColorReset + theme . StopUnderline + "\n " , ctfTimeUrl )
165
177
166
178
if strings .Contains (ctfTimeUrl , "ctftime.org" ) {
167
179
showInfo (& infos [idx ])
0 commit comments