~psic4t/qcal

ff410605a0c6f6e52d72474d5e30f825f85b8752 — psic4t 8 months ago 9af2d98
fix timezone parsing
4 files changed, 10 insertions(+), 8 deletions(-)

M README.md
M defines.go
M main.go
M parse.go
M README.md => README.md +1 -1
@@ 1,6 1,6 @@
# qcal

qcal is a quick calendar application for CalDAV servers written in Go. In
qcal is a CLI calendar application for CalDAV servers written in Go. In
contrast to other tools it does not cache anything. It can fetch multiple
servers / calendars in parallel which makes it quite fast.


M defines.go => defines.go +2 -2
@@ 24,12 24,12 @@ var endDateUTC string
var summary string
var toFile bool

// var colorBlock string = "█"
//var colorBlock string = "█"
var colorBlock string = "|"
var elements []Event
var Colors = [10]string{"\033[0;31m", "\033[0;32m", "\033[1;33m", "\033[1;34m", "\033[1;35m", "\033[1;36m", "\033[1;37m", "\033[1;38m", "\033[1;39m", "\033[1;40m"}
var showColor bool = true
var qcalversion string = "0.8.4"
var qcalversion string = "0.8.5"

const (
	ConfigDir      = ".config/qcal"

M main.go => main.go +1 -1
@@ 255,7 255,7 @@ func main() {
	showCalendars := flag.Bool("l", false, "List configured calendars with their corresponding numbers (for \"-c\")")
	appointmentFile := flag.String("u", "", "Upload appointment file. Provide filename and use with \"-c\"")
	appointmentDelete := flag.String("d", "", "Delete appointment. Get filename with \"-f\" and use with \"-c\"")
	appointmentDump := flag.String("dump", "", "Dump raw  appointment data. Get filename with \"-f\" and use with \"-c\"")
	appointmentDump := flag.String("dump", "", "Dump raw appointment data. Get filename with \"-f\" and use with \"-c\"")
	appointmentEdit := flag.String("edit", "", "Edit + upload appointment data. Get filename with \"-f\" and use with \"-c\"")
	appointmentData := flag.String("n", "", "Add a new appointment. Check README.md for syntax")
	flag.Parse()

M parse.go => parse.go +6 -4
@@ 67,6 67,8 @@ func parseTimeField(fieldName string, eventData string) (time.Time, string) {

	resultWholeDay := reWholeDay.FindString(eventData)
	var t time.Time
	var thisTime time.Time
	//var thisTime time.Time
	//var datetime time.Time
	var tzID string
	var format string


@@ 86,7 88,6 @@ func parseTimeField(fieldName string, eventData string) (time.Time, string) {
		tzID = result[2]
		dt := strings.Trim(result[4], "\r") // trim that newlines!

		//	myLocation, _ := time.LoadLocation("Europe/Berlin")
		if strings.HasSuffix(dt, "Z") {
			// If string ends in 'Z', timezone is UTC
			format = "20060102T150405Z"


@@ 98,11 99,12 @@ func parseTimeField(fieldName string, eventData string) (time.Time, string) {
			location, err := time.LoadLocation(tzID)
			// if tzID not readable use configured timezone
			if err != nil {
				location, _ = time.LoadLocation(timezone)
				location, _ = time.LoadLocation(config.Timezone)
				// timezone from defines gives CEST, which is not working with parseinlocation:
				//location, _ = time.LoadLocation(timezone)
			}
			// set foreign timezone
			thisTime, _ := time.ParseInLocation(format, dt, location)
			//fmt.Println(time)
			thisTime, _ = time.ParseInLocation(format, dt, location)
			// convert to local timezone
			//t = time.In(myLocation)
			t = thisTime.Local()