summaryrefslogtreecommitdiff
path: root/init.go
blob: b572477cd410d85463799f2dbe7962304d3f41a3 (plain)
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
package argvpb

import (
	"time"

	"go.wit.com/lib/cobol"
	"go.wit.com/log"
)

// gets APPNAME, BUILDTIME and VERSION from the application
func initAppname() {
	app := new(App)
	APPNAME, anyString, VERSION := me.initArgvFunc()
	app.APPNAME = APPNAME
	app.VERSION = VERSION
	//
	// this logic isn't great, but it's what it is right now
	//
	// the reason this logic is messy is because cobol is supposed to "guess"
	// that is the point of the cobol package and I've been using this code here
	// to test the guesses because it's an easy place to test that code
	//
	if BUILDTIME, err := cobol.GetTime(anyString); BUILDTIME != nil {
		// everyhting is working. BUILDTIME is *time.Time
		app.BUILDTIME = cobol.Time(BUILDTIME)
	} else if err == nil {
		newtime := BUILDTIME.Add(-36 * time.Hour)
		app.BUILDTIME = cobol.Time(BUILDTIME)
		log.Printf("TIME initAppname() ERR=(%v) anyString=(%v) GetTime.BUILTIME=(%v) app.BUILDTIME=(%v)\n", err, anyString, newtime, app.BUILDTIME)
	} else {
		app.BUILDTIME = anyString
		log.Printf("TIME initAppname() ERR=(%v) anyString=(%v) GetTime.BUILTIME=(%v) app.BUILDTIME=(%v)\n", err, anyString, BUILDTIME, app.BUILDTIME)
	}
	me.pb.AppInfo = app
}