forked from spezifisch/stmps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
40 lines (32 loc) · 821 Bytes
/
helpers.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
// Copyright 2023 The STMPS Authors
// SPDX-License-Identifier: GPL-3.0-only
package main
import "math"
const (
clientName = "stmps"
clientVersion = "0.9.9"
)
var (
clientCommitHash string
)
// Set commit hash
func SetCommitHash(hash string) {
clientCommitHash = hash
}
// if the first argument isn't empty, return it, otherwise return the second
func stringOr(firstChoice string, secondChoice string) string {
if firstChoice != "" {
return firstChoice
}
return secondChoice
}
func secondsToMinAndSec(seconds int64) (int, int) {
minutes := math.Floor(float64(seconds) / 60)
remainingSeconds := int(seconds) % 60
return int(minutes), remainingSeconds
}
func iSecondsToMinAndSec(seconds int) (int, int) {
minutes := seconds / 60
remainingSeconds := seconds % 60
return minutes, remainingSeconds
}