~psic4t/qcal

ref: 60590b9b590761be4b249d3e19b6b126e8267b85 qcal/defines.go -rw-r--r-- 3.1 KiB
60590b9bpsic4t support attendees in additional info 3 months ago
                                                                                
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package main

import (
	"encoding/xml"
	"os"
	"time"
)

var err string
var homedir string = os.Getenv("HOME")
var editor string = os.Getenv("EDITOR")
var configLocation string = (homedir + "/" + ConfigDir + "/config.json")
var cacheLocation string = (homedir + "/" + CacheDir)
var versionLocation string = (cacheLocation + "/version.json")
var timezone, _ = time.Now().Zone()
var xmlContent []byte
var showInfo bool
var showFilename bool
var displayFlag bool
var startDate string
var endDate string
var startDateUTC string
var endDateUTC string
var summary string
var toFile bool
var elements []Event
var qcalversion string = "0.8.6"

var colorBlock string = "|"
var currentDot string = "•"
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

const (
	ConfigDir      = ".config/qcal"
	CacheDir       = ".cache/qcal"
	dateFormat     = "02.01.06"
	dayMonthFormat = "02.01"
	timeFormat     = "15:04"
	RFC822         = "02.01.06 15:04"
	// ics date format ( describes a whole day)
	IcsFormat   = "20060102T150405"
	IcsFormatTZ = "TZID=MST:20060102T150405"
	//IcsFormatTZ         = "20060102T150405Z -0700"
	IcsFormatWholeDay   = "20060102"
	IcsFormatWholeMonth = "200601"
	IcsFormatMonthDay   = "0102"
	IcsFormatTime       = "T150405Z"
	Weekday             = "Mon"
	IcsFormatYear       = "2006"
	ColWhite            = "\033[1;37m"
	ColDefault          = "\033[0m"
	ColGreen            = "\033[0;32m"
	ColYellow           = "\033[1;33m"
	ColBlue             = "\033[1;34m"
)

type configStruct struct {
	Calendars []struct {
		Url      string
		Username string
		Password string
	}
	Timezone       string
	DefaultNumDays int
}

type Event struct {
	Href        string
	Color       string
	Start       time.Time
	End         time.Time
	TZID        string
	Freq        string
	Summary     string
	Description string
	Location    string
	Attendees   []string
}

type xmlProps struct {
	calNo        string
	Url          string
	XMLName      xml.Name `xml:"multistatus"`
	Href         string   `xml:"response>href"`
	DisplayName  string   `xml:"response>propstat>prop>displayname"`
	Color        string   `xml:"response>propstat>prop>calendar-color"`
	CTag         string   `xml:"response>propstat>prop>getctag"`
	ETag         string   `xml:"response>propstat>prop>getetag"`
	LastModified string   `xml:"response>propstat>prop>getlastmodified"`
}

type calProps struct {
	calNo       int
	displayName string
	url         string
	color       string
}

type Caldata struct {
	XMLName xml.Name     `xml:"multistatus"`
	Caldata []Calelement `xml:"response"`
}

type Calelement struct {
	XMLName xml.Name `xml:"response"`
	Href    string   `xml:"href"`
	ETag    string   `xml:"propstat>prop>getetag"`
	Data    string   `xml:"propstat>prop>calendar-data"`
}

var calSkel = `BEGIN:VCALENDAR
		VERSION:2.0
		CALSCALE:GREGORIAN
		PRODID:-//qcal
		BEGIN:VEVENT
		TZID:` + timezone + `
		DTSTART;TZID=` + timezone + `:20191011T193000Z
		DTEND;TZID=` + timezone + `:20191011T123000Z
		DTSTAMP:20190930T141136Z
		SUMMARY:Training mit Eric
		END:VEVENT
		END:VCALENDAR`