-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogrammi.go
49 lines (40 loc) · 1.04 KB
/
programmi.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
41
42
43
44
45
46
47
48
49
package main
type Programmi struct {
Start []interface{} `json:"start"`
BlogID int `json:"blog_id"`
End []interface{} `json:"end"`
BlogURL string `json:"blog_url"`
Title string `json:"title"`
Stato string `json:"stato"`
Logo struct {
URL string `json:"url"`
Descr string `json:"descr"`
Title string `json:"title"`
} `json:"logo"`
ID int `json:"id"`
}
type Schedule struct {
Programmi []Programmi `json:"programmi"`
Adesso struct {
Start []string `json:"start"`
End []string `json:"end"`
ID int `json:"id"`
Title string `json:"title"`
} `json:"adesso"`
}
type SortedProgrammi []Programmi
func (s SortedProgrammi) Len() int {
return len(s)
}
func (s SortedProgrammi) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s SortedProgrammi) Less(i, j int) bool {
a := s[i].Start
b := s[j].Start
a_hour := a[1].(float64)
b_hour := b[1].(float64)
a_minute := a[2].(float64)
b_minute := b[2].(float64)
return a_hour < b_hour || a_hour == b_hour && a_minute < b_minute
}